Using GitLab to store source-code for technical papers and books

Do you use (a) GitLab repo(s) for code used in papers, books, conference talks, etc?

Is there a tool which will embed repo-resident code into a word-processor (or similar) document?

  • dynamic connection (doc reflects when code is updated)
  • line numbers added, or ignored
  • distinctive style from text
  • etc

Please advise =dn

Hi d_n. Thanks for posting.

It sounds like you’re looking for way to connect your code repository to a word document or other word processor so that the word document will “know” when the code is updated and reflect it in the document. The only way I can think of this is having a variable in your word processor and having that variable somehow connect to your most recent repo. We don’t have a tool for this, it would instead involve writing a custom script to make happen. I know that if you use a snippet, you can clone or embed the snippet somewhere, but the only way I think it would dynamically connect is with the embed script, but since that’s HTML I’m not sure how to make it work with a word processor. Here’s more on snippets.

What I can suggest is writing your entire paper, book, or talk in markdown on GitLab and saving it in a repo with the code in a separate file. You can insert code blocks into your markdown. This isn’t a dynamic solution, but it could make it easier by having all your work in one repo rather than a repo and a word processor. I googled some ways to convert markdown to a PDF. I haven’t verified that online tool, but there were several results on google for it.

I hope this is helpful!

Pj

1 Like