Skip to content

Commit 8e9bbcd

Browse files
committed
A few changes to undo some of what was done diegobz and correcting a few changes I've missed.
1 parent 6b2602b commit 8e9bbcd

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
*.rst
21
*~
32
markdown_include.egg-info/
43
dist/

README.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+

markdown_include/include.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def extendMarkdown(self, md, md_globals):
5252
class IncludePreprocessor(Preprocessor):
5353
'''
5454
This provides an "include" function for Markdown, similar to that found in
55-
LaTeX (also the C pre-processor and Fortran). The syntax is {{filename}},
55+
LaTeX (also the C pre-processor and Fortran). The syntax is {!filename!},
5656
which will be replaced by the contents of filename. Any such statements in
5757
filename will also be replaced. This replacement is done prior to any other
5858
Markdown processing. All file-names are evaluated relative to the location

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
here = path.abspath(path.dirname(__file__))
66

77
# Get the long description from the relevant file
8-
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
8+
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
99
long_description = f.read()
1010

1111
setup(

0 commit comments

Comments
 (0)