|
| 1 | +Markdown-Include |
| 2 | +================ |
| 3 | + |
| 4 | +This is an extension to |
| 5 | +`Python-Markdown <https://pythonhosted.org/Markdown/>`__ which provides |
| 6 | +an "include" function, similar to that found in LaTeX (and also the C |
| 7 | +pre-processor and Fortran). I originally wrote it for my |
| 8 | +`FORD <https://pypi.python.org/pypi/FORD>`__ Fortran auto-documentation |
| 9 | +generator. |
| 10 | + |
| 11 | +Installation |
| 12 | +------------ |
| 13 | + |
| 14 | +This module can now be installed using ``pip``. |
| 15 | + |
| 16 | +:: |
| 17 | + |
| 18 | + pip install markdown-include |
| 19 | + |
| 20 | +Usage |
| 21 | +----- |
| 22 | + |
| 23 | +This module can be used in a program in the following way: |
| 24 | + |
| 25 | +:: |
| 26 | + |
| 27 | + import markdown |
| 28 | + html = markdown.markdown(source, extensions=[markdown_include.include']) |
| 29 | + |
| 30 | +The syntax for use within your Markdown files is ``{!filename!}``. This |
| 31 | +statement will be replaced by the contents of ``filename``. |
| 32 | +Markdown-Include will work recursively, so any included files within |
| 33 | +``filename`` wil also be included. This replacement is done prior to any |
| 34 | +other Markdown processing, so any Markdown syntax that you want can be used |
| 35 | +within your included files. Note that this is a change from the previous |
| 36 | +version. It was felt that this syntax was less likely to conflict with any code |
| 37 | +fragments present in the Markdown. |
| 38 | + |
| 39 | +By default, all file-names are evaluated relative to the location from |
| 40 | +which Markdown is being called. If you would like to change the |
| 41 | +directory relative to which paths are evaluated, then this can be done |
| 42 | +by specifying the extension setting ``base_path``. |
| 43 | + |
| 44 | +:: |
| 45 | + |
| 46 | + import markdown |
| 47 | + from markdown_include.include import MarkdownInclude |
| 48 | + |
| 49 | + # Markdown Extensions |
| 50 | + markdown_include = MarkdownInclude( |
| 51 | + configs={'base_path':'/srv/content/', 'encoding': 'iso-8859-1'} |
| 52 | + ) |
| 53 | + html = markdown.markdown(source, extensions=[markdown_include]) |
| 54 | + |
0 commit comments