Skip to main content

A tool to inline content in a Deckset Markdown file

Project description

Deckset Inline

Include content from other files in your Deckset slides.

Okay how?

First install the tool:

pip install deckset-inliner

Then prepare a file from which you want to include some content. This is a_file.py:

print("Hello I am a text file, but this line is not interesting.")
print("This second line, though, is vital for any presentation.")
print("This third line should be included too.")
print("But not this fourth one, don't care for this one.")

Then add an opening inline directive and a closing inline directive to your presentation Markdown file, where you want the content to appear:

<!-- <inline src="a_file.py" verbatim lang="python" start="2" end="3"> -->
<!-- </inline> -->

Then run the tool with your presentation file:

deckset-inliner --in-place --backup-ext bak slides.md

See how your file has been modified in-place, and you now have the lines 2 to 3 of a_file.py included between the directives:

<!-- <inline src="a_file.py" verbatim lang="python" start="2" end="3"> -->
```python
print("This second line, though, is vital for any presentation.")
print("This third line should be included too.")
```
<!-- </inline> -->

See how the directives stay? You can now run the command again after you change the source files.

I see, but why?

I want to test the code that I put in my slides, so I write it in proper code files that I then run and test (Yes, I sometimes write tests for the code in my slides). If I find an issue with the code, I don't want to be copy-pasting code into the slides again. This tools takes care of that for me.

Okay, I want this, tell me more

Welcome!

Directives are one line HTML comments with a home made tag inside. The basic directive has the tag name inline and these are the available attributes:

  • src: The only mandatory attribute, it specifies the path of the file to include.
  • verbatim: A flag. When present (it takes no value), the included code will be surrounded by lines with 3 backtics each ```
  • lang: Implies verbatim. Specifies the language that will appear at the top of the backticks block.
  • start: The first line of the source file (counted starting at 1) that will appear in the block.
  • end: The last line of the source file (counted starting at 1) that will appear in the block.

For convenience, I've added a second directive called python, which is equivalent of setting lang="python" on an inline directive.

The tool puts its output on stdout by default, like sed does, only if you pass the -i (--in-place) flag it will modify the original file. I recommend you also use the -b (--backup-ext) flag to force the creation of a backup of your file, if you aren't using version control for your slides.

There is also an option (-c or --clean) which deletes all the content between opening and closing directives, while leaving the directives themselves intact.

Any caveats?

  • The inline operation is not recursive, and the tool will not handle well if you include files that contain other directives.
  • The parsing is quite rudimentary and line based, so directives cannot span across multiple lines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deckset-inline-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deckset_inline-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file deckset-inline-0.1.0.tar.gz.

File metadata

  • Download URL: deckset-inline-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.0

File hashes

Hashes for deckset-inline-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2e3fae535a79eb3a36fd4326b9f0f0512157561108bcdd09eb6bee39788b9f0
MD5 d4374b8e0a74a20c790e0c5808d99a9f
BLAKE2b-256 c3751fd3369a364ec0fd7460fd83eae8ea2987f54d624302e9d5bfea5d161c80

See more details on using hashes here.

File details

Details for the file deckset_inline-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: deckset_inline-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.0

File hashes

Hashes for deckset_inline-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0135622d9709eec93b473677b5b73d15d00128f9eb7c9c1be8898ad787999b5
MD5 22b628e9856b6891ab10f04dd369394c
BLAKE2b-256 854ea71aaa45448a9dbca7aebac351e0bff5ab12130002ca60461c2be2aa1dbf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page