Giter Club home page Giter Club logo

markdown-pp's Introduction

Markdown Preprocessor (MarkdownPP)

NOTICE: This project is no longer actively maintained. It will not receive any future releases.

The Markdown Preprocessor is a Python module designed to add extended features on top of the excellent Markdown syntax defined by John Gruber. These additions are mainly focused on creating larger technical documents without needing to use something as heavy and syntactically complex as Docbook.

MarkdownPP uses a set of selectable modules to apply a series of transforms to the original document, with the end goal of generating a new Markdown document that contains sections or features that would be laborious to generate or maintain by hand.

Documents designed to be preprocessed by MarkdownPP should try to follow the convention of naming files with a .mdpp extension, so that MarkdownPP can generate a document with the same name, but with the standard .md extension. As an example, this document in raw format is named "readme.mdpp", and the generated document from MarkdownPP is named "readme.md" so that GitHub can find and process that document when viewing the repository.

Build Status

1. Installation and Usage
2. Modules
2.1. Includes
2.2. IncludeURLs
2.3. IncludeCode
2.4. Table of Contents
2.5. Reference
2.6. LaTeX Rendering
2.7. YouTube Embeds
3. Examples
4. Support
5. References

1. Installation and Usage

Currently, you'll need to download the source code from GitHub or clone the repository, and the run the installation script manually.

pip install MarkdownPP

There are two components to the project: a Python module, MarkdownPP, and a Python script that acts as a simple command line interface to the module, markdown-pp.

Assuming you have a file named foo.mdpp, you can generate the preprocessed file foo.md by running the following command:

$ markdown-pp foo.mdpp -o foo.md

If you do not specify an output file name, the results will be printed to stdout, enabling them to be piped to another command.

By default, all available modules are enabled. You can specify a list of modules to exclude:

$ markdown-pp foo.mdpp -o foo.md -e latexrender,youtubembed

To see usage instructions, including a list of enabled modules, supply the -h or --help arguments:

$ markdown-pp --help

2. Modules

2.1. Includes

In order to facilitate large documentation projects, MarkdownPP has an Include module that will replace a line of the form !INCLUDE "path/to/filename" with the contents of that file, recursively including other files as needed.

File foo.mdpp:

Hello

File bar.mdpp:

World!

File index.mdpp:

!INCLUDE "foo.mdpp"
!INCLUDE "bar.mdpp"

Compiling index.mdpp with the Include module will produce the following:

Hello
World!

Furthermore, the Include module supports the shifting of headers in the file to be included. For example,

File foo.mdpp:

# Foo
## Bar

File index.mdpp:

# Title
## Subtitle
!INCLUDE "foo.mdpp", 2

Compiling index.mdpp with the Include module and using 2 as shift parameter will yield:

# Title
## Subtitle
### Foo
#### Bar

2.2. IncludeURLs

Facilitates the inclusion of remote files, such as files kept in a subversion or GitHub repository. Like Include, the IncludeURL module can replace a line of the form !INCLUDEURL "http://your.domain/path/to/filename" with the contents returned from that url, recursively including additional remote urls as needed.

IncludeURL runs immediately after the Include module finishes executing. This means that is it possible to include local files that then require remote files, but impossible parse !INCLUDE statements found in remote files. This is prevent ambiguity as to where the file would be located.

Remote file http://your.domain/foo.mdpp:

Hello

Remote file http://your.domain/bar.mdpp:

Remote World!

Local file index.mdpp:

!INCLUDEURL "http://your.domain/foo.mdpp"
!INCLUDEURL "http://your.domain/bar.mdpp"

Compiling index.mdpp with the IncludeURL module will produce the following:

Hello
Remote World!

2.3. IncludeCode

Facilitates the inclusion of local code files. GFM fences will be added around the included code.

Local code file hello.py:

def main():
    print "Hello World"


if __name__ == '__main__':
    main()

Local file index.mdpp:

# My Code

!INCLUDECODE "hello.py"
Easy as that!

Compiling index.mdpp with IncludeCode module wil produce the following:

# My Code

```
def main():
    print "Hello World"


if __name__ == '__main__':
    main()
```
Easy as that!

Furthermore the IncludeCode module supports line extraction and language specification. The line extraction is like python list slicing (e.g. 3:6; lines three to six). Please note that line counting starts at one, not at zero.

Local file index.mdpp:

# My Code

!INCLUDECODE "hello.py" (python), 1:2
Easy as that!

Compiling index.mdpp with IncludeCode module will produce the following:

# My Code

```python
def main():
    print "Hello World"
```
Easy as that!

2.4. Table of Contents

The biggest feature provided by MarkdownPP is the generation of a table of contents for a document, with each item linked to the appropriate section of the markup. The table is inserted into the document wherever the preprocessor finds !TOC at the beginning of a line. Named <a> tags are inserted above each Markdown header, and the headings are numbered hierarchically based on the heading tag that Markdown would generate.

2.5. Reference

Similarly, MarkdownPP can generate a list of references that follow Markdown's alternate link syntax, eg [name]: <url> "Title". A list of links will be inserted wherever the preprocessor finds a line beginning with !REF. The generated reference list follows the same alternate linking method to ensure consistency in your document, but the link need not be referenced anywhere in the document to be included in the list.

2.6. LaTeX Rendering

Lines and blocks of lines beginning and ending with $ are rendered as LaTeX, using QuickLaTeX.

For example,

$\displaystyle \int x^2 = \frac{x^3}{3} + C$

becomes

\displaystyle \int x^2 = \frac{x^3}{3} + C

2.7. YouTube Embeds

As GitHub-flavored Markdown does not allow embed tags, each line of the form !VIDEO "[youtube url]" is converted into a screenshot that links to the video, roughly simulating the look of an embedded video player.

For example,

!VIDEO "http://www.youtube.com/embed/7aEYoP5-duY"

becomes

Link to Youtube video

3. Examples

Example file.mdpp:

# Document Title

!TOC

## Header 1
### Header 1.a
## Header 2

!REF

[github]: http://github.com "GitHub"

The preprocessor would generate the following Markdown-ready document file.md:

# Document Title

1\. [Header 1](#header1)
1.1\. [Header 1.a](#header1a)
2\. [Header 2](#header2)

<a name="header1"></a>
## Header 1
<a name="header1a"></a>
### Header 1.a
<a name="header2"></a>
## Header 2

*	[GitHub][github]

[github]: http://github.com "GitHub"

4. Support

While the project should work on most recent versions of Python, this project is no longer supported.

5. References

markdown-pp's People

Contributors

alexnisnevich avatar amyreese avatar douglasurner avatar frank-krick avatar georgesk avatar jamesscottbrown avatar johnathonnow avatar joshjordan avatar kennethkau avatar pkorpine avatar simonvh avatar smartsoftwaresd avatar thierryvolpiatto avatar vincenzolaspesa avatar zgrannan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markdown-pp's Issues

Wonky mangulation of header tags when creating <a> tags for !TOC

This file, test1.mdpp:

# test.mdpp -- **H1**

## Table of Contents below -- \<H2\>
!TOC

## Test H2 that includes "some things in quotes" ##
Moar text

Produces this:

# test2.mdpp -- **H1**

## Table of Contents below -- \<H2\>
1\.  [Test H2 that includes "some things in quotes" ##](#testh2thatincludes"somethingsinquotes"##)

<a name="testh2thatincludes"somethingsinquotes"##"></a>

## 1\. Test H2 that includes "some things in quotes" ##
Moar text

The header that has quoted text completely baffle the link creator and it puts together a name field that is strings of stuff with embedded double quotes and bare strings that shouldn't be valid even if they can accidentally be parsed. Who knows what evil lurks within the hearts of HTML parsers, really?

I didn't get any further than that in my current explorations because I'm really only after the !INCLUDE functionality, but some docs with warnings or smartening up the tag creator (with some edge-case bending tests) might be in order.

I don't have time to create a pull request now, I just wanted to record this before it got away.

Recursive call over a directory

I have several .mdpp files scattered inside a content/ directory, and it would be really useful to be able to do something like

markdown-pp -r content/

and have it run recursively on every .mdpp it finds.

I know there's the -w flag, but having markdown-pp on the background watching every change is not really fitting to my workflow. I would like to control when I generate the .md files and would like to be able to do it all at once.

If there's interest, I can prepare a PR promptly.

Choose different output encoding in Windows

It seems that the output encoding in Windows is cp1252 by default which creates problems when the source files contain unicode characters if there is no suitable character defined in the charmap.

When I try to process a document containing the character '●' with MarkdownPP on Windows it exits with the following error:

Traceback (most recent call last):
  File "C:\Users\frank\AppData\Local\Programs\Python\Python37\Scripts\markdown-pp-script.py", line 11, in <module>
    load_entry_point('MarkdownPP==1.4', 'console_scripts', 'markdown-pp')()
  File "C:\Users\frank\AppData\Local\Programs\Python\Python37\lib\site-packages\MarkdownPP\main.py", line 112, in main
    MarkdownPP.MarkdownPP(input=mdpp, output=md, modules=modules)
  File "C:\Users\frank\AppData\Local\Programs\Python\Python37\lib\site-packages\MarkdownPP\MarkdownPP.py", line 28, in __init__
    pp.process()
  File "C:\Users\frank\AppData\Local\Programs\Python\Python37\lib\site-packages\MarkdownPP\Processor.py", line 49, in process
    transforms = module.transform(self.data)
  File "C:\Users\frank\AppData\Local\Programs\Python\Python37\lib\site-packages\MarkdownPP\Modules\Include.py", line 39, in transform
    includedata = self.include(match)
  File "C:\Users\frank\AppData\Local\Programs\Python\Python37\lib\site-packages\MarkdownPP\Modules\Include.py", line 70, in include
    data[linenum:linenum+1] = self.include(match, dirname)
  File "C:\Users\frank\AppData\Local\Programs\Python\Python37\lib\site-packages\MarkdownPP\Modules\Include.py", line 61, in include
    data = f.readlines()
  File "C:\Users\frank\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 6569: character maps to <undefined>

The same input can be processed fine using Linux.

Is there a way to install Markdown-PP if a linux distribution is not supported by it?

When installing with:
pip install Markdown-PP
I get:

Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement Markdown-PP (from versions: none)
ERROR: No matching distribution found for Markdown-PP

So here's a question, is there a way to install Markdown-PP different way? It's weird that I can't install it now. Couple of weeks later the installation went smoothly.

btw I use arch

File Encoding should be given in command line

If I use !TOC and non-ascii chracters. I get following error.

  File "/home/atilla/anaconda/bin/markdown-pp", line 42, in <module>
    MarkdownPP.MarkdownPP(input=mdpp, output=md, modules=modules)
  File "/home/atilla/anaconda/lib/python2.7/site-packages/MarkdownPP/MarkdownPP.py", line 30, in __init__
    pp.process()
  File "/home/atilla/anaconda/lib/python2.7/site-packages/MarkdownPP/Processor.py", line 49, in process
    transforms = module.transform(self.data)
  File "/home/atilla/anaconda/lib/python2.7/site-packages/MarkdownPP/Modules/TableOfContents.py", line 119, in transform
    TableOfContents.clean_title(title)).lower()
  File "/home/atilla/anaconda/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 3: ordinal not in range(128)

Inline math problem

Hello,
Whenever I try to inline math in a mdpp file, markdown-pp returns a weird output. For example, for the input:
$2^n$

The output is:

![2^n](<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
</body>
</html> "2^n")

I have tested this both on Python 2.7.15 and 3.6.8.

Enhancement of the include directive

Can the include directive search set of paths provided via an environment variable. This will make things lot easier. Current design constrains the location of the include files.

I suggest :
export MARKDOWN_INCLUDE_PATH =x/y/z
markdown-pp <input.mdpp> -o <output.md>

I am not familiar with python, I don't know where to modify the code. I find the markdown-pp very handy. However it is limiting me in the auto generation of master markdown file from multiple small files due to the need for relative directory location.

$ not redering

Love markdown-pp, but having trouble with the $ character

Electric standing desks range from $200-$2000.

Rendering: 200-2000. A survey found standing desk advocates would be happy with the ...
Traceback (most recent call last):
File "/usr/local/bin/markdown-pp", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/MarkdownPP/main.py", line 112, in main
MarkdownPP.MarkdownPP(input=mdpp, output=md, modules=modules)
File "/usr/local/lib/python2.7/site-packages/MarkdownPP/MarkdownPP.py", line 28, in init
pp.process()
File "/usr/local/lib/python2.7/site-packages/MarkdownPP/Processor.py", line 49, in process
transforms = module.transform(self.data)
File "/usr/local/lib/python2.7/site-packages/MarkdownPP/Modules/LaTeXRender.py", line 77, in transform
self.render(tex) +
File "/usr/local/lib/python2.7/site-packages/MarkdownPP/Modules/LaTeXRender.py", line 100, in render
formula = formula.replace("$", "")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 163: ordinal not in range(128)

Tried with \$ and I get the same error

Rendering: 200-\2000. A survey found standing desk advocates would be happy with the ...
Traceback (most recent call last):

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 163: ordinal not in range(128)

Add custom modules?

Over in #40 you said:

@jreese
then I'd rather see those implemented as custom modules instead.

Is there a way to add modules that I just missed? As far as I can tell, whatever's in the MarkdownPP/Modules directory gets pulled in but I don't see where the code looks elsewhere.

Even a command line switch like:

-m <extra-modules-path>

Possibly repeated and/or with paths delimited by e.g. ":" would probably be sufficient.

Looks like it'd just have to be searched and added to the list after the built-in modules by exactly the same mechanism and, assuming they conform to the very simple API, should work a treat as they used to say in the olden days.

Yes, no, maybe?

!INCLUDE should support a shift parameter

Hello,

it will be nice if !INCLUDE could have a shift parameter.

01.md looks like

# Title 1
## Title 1.1
## Title 1.2
# Title 2
## Title 2.1
## Title 2.2

01_sub.md looks like

I would like to get a Mardown document like

# Title 1
## Title 1.1
## Title 1.2
# Title 2
## Title 2.1
## Title 2.2
### SubTitle 1
#### SubTitle 1.1
#### SubTitle 1.2
### SubTitle 2
#### SubTitle 2.1
#### SubTitle 2.2

index.mdpp

!INCLUDE "01.md"
!INCLUDE "01_sub.md", 2

2 would be this shift parameter

What is your opinion about it ?

Kind regards

Include *.md?

Is it possible to include all .md files in a directory alphabetically without creating an include for each one? Is anything similar to this possible?

Installation issue with accents

Hey !

I have been struggling with installing markdown-pp.
I'm not a python dev so it took me a while to figure out why, and it turned out accents in the installation path are not handled (my first name is "Sébastien").

I had to reinstall Python and markdown-pp in a accent-free path.
Maybe worth mentioning in the documentation at least ?

Good job anyway ! 👍

!INCLUDE with shift will shift lines inside code blocks

For example using the include statement !INCLUDE "path/to/file.md", 2 on a file containing the following code block,

# uname -a
Linux mymachine 4.18.0-0.bpo.1-amd64 #1 SMP Debian 4.18.6-1~bpo9+1 (2018-09-13) x86_64 GNU/Linux

the resulting file will contain the following,

### uname -a
Linux mymachine 4.18.0-0.bpo.1-amd64 #1 SMP Debian 4.18.6-1~bpo9+1 (2018-09-13) x86_64 GNU/Linux

This is because the regex on the file MarkdownPP/Modules/Include.py does not detect if it is inside a code block. I did a dirty fix as shown below (lines with ## HERE).

MarkdownPP/Modules/Include.py:

    ...

    # matches title lines in Markdown files
    titlere = re.compile(r"^(:?#+.*|={3,}|-{3,})$")
    
    # matches code block start and stop
    codeblockre = re.compile(r"```")  ## HERE

    # includes should happen before anything else
    priority = 0

    ...

    def include_file(self, filename, pwd="", shift=0):
        try:
            f = open(filename, "r")
            data = f.readlines()
            f.close()
            in_codeblock = False

            # line by line, apply shift and recursively include file data
            linenum = 0
            for line in data:
                match = self.includere.search(line)

                if self.codeblockre.search(line):  ## HERE
                    in_codeblock = not in_codeblock  ## HERE

                if match:
                    dirname = path.dirname(filename)
                    data[linenum:linenum+1] = self.include(match, dirname)
                    # Update line so that we won't miss a shift if
                    # heading is on the 1st line.
                    line = data[linenum]

                if shift:

                    titlematch = self.titlere.search(line)
                    if titlematch and not in_codeblock:  ## HERE
                        to_del = []
                        for _ in range(shift):
                            if data[linenum][0] == '#':
                                data[linenum] = "#" + data[linenum]
                            elif data[linenum][0] == '=':
                                data[linenum] = data[linenum].replace("=", '-')
                            elif data[linenum][0] == '-':
                                data[linenum] = '### ' + data[linenum - 1]
                                to_del.append(linenum - 1)
                        for l in to_del:
                            del data[l]


                linenum += 1

            return data

        except (IOError, OSError) as exc:
            print(exc)

        return []

    ...

Note: I'm sorry, I'm not very Github savvy.

To what location should the filepath be relative in an !INCLUDE instruction?

I have tried to make it relative to the current working directory, but markdown-pp does not seem to find the file. I tried to make it relative to the location of the file being processed, but that does not work either. How does it work?

By the way, markdown-pp does not give any error message when it cannot find a an !INCLUDE file. It just produces an empty file in my case ...

Directory watching and auto-processing

Hello,

Would having a watch flag which watches a directory (and subdirectories) and processes any changing .mdpp file be useful?

For example: "markdown-pp -w ." will watch the current directory for any .mdpp file and generate the corresponding markdown file with the same filename but with an .md extension.

Thanks!

Struggling with $ in md file

Hi,

I'm trying to use this to stick together a bunch of MD files that have $ signs in them. That seems to cause a render error. It doesn't if the $ is formatted as code.

I didn't go digging to fix it. Sorry.

-Ben

Demoted !INCLUDE converts pandoc YAML header to ATX header

!INCLUDE "file.md", 1 converts any YAML --- start markers to ### and copies the last line of the file as an ATX header. All headers in the file are ATX. Bare !INCLUDE "file.md" does not have the problem. It may be detecting a YAML marker as a SETEXT header but not checking the length of the line above to validate detection.

The work-around is pandoc file.md --atx-headers --to markdown --output tmp/file.md and change the mdpp file to !INCLUDE "tmp/file.md", 1. The mdpp file needs to include any desired YAML headers.

any advices on where to process images path in md # INCLUDE module

since I can !INCLUDE a md file into a merged one, but the md file to be included may have relative path point to some images, the final merged md may have a wrong image path reference, when compile with pandoc or some markdown processor, the path link will broken.

do u guys have any advice on how to handle such situation?

let's say, index.mdpp INCLUDE chapters/chapter1/section1.md, and section1.md refers to relative images/image1.png, in generated index.md, the image path should be chapters/chapter1/images/image1.png

index.mdpp
index.md (generated)
chapters/
     chapter1/
          images/
               image1.png
          seciton1.md
          section2.md
          ...
     chapter2/
.....

Version bump

Is it possible to increment the version now that the INCLUDECODE functionality has been added?

This will make it easier to include the new functionality in third-party repositories (e.g NixOS/nixpkgs#43525)

--- Generates a heading in the TOC

Whenever I use a horizontal rule in Markdown, MarkdownPP generates a heading in the TOC.

A horizontal rule in Markdown:
---

The result after using MarkdownPP:

<a name=""></a>

9.6\. 
9.6\. ------

Found a bug and here's how to fix

Sorry, I don't know anything about github or python really, so I'm probably submitting this improperly.

Markdown-PP doesn't work when a file has the wrong kind of encoding. This can be fixed by changing

       try:
            f = open(filename, "r")

to

       try:
            f = open(filename, "r", encoding='utf-8')

in the file Include.py.

Add support for globbing to INCLUDE (Pull request 59) breaks recursive includes with relative paths

The change to include globbing breaks relative paths with recursive includes.
The current directory has to be added in the method include not in the
method include_file otherwise glob.glob does not find anything and
the line will be replaced with an empty array which leads to index out of
bound access later.

Additionally, currently, empty globs create list index out of bounds errors
during execution. This happens because calling include returns an
empty list in that case, therefore removing a line in the file that the
code afterwards assumes still exists.

Special characters in heading break TOC generation

When generating a table of contents with a heading that contains a special unicode character such as ® fails:

Test markdown:

# Test document

!TOC

## Test ® Test

The following is a test.

markdown-pp error output:

❯ markdown-pp test_pp.md -o test.md                   
Traceback (most recent call last):
  File "/usr/local/bin/markdown-pp", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/MarkdownPP/main.py", line 112, in main
    MarkdownPP.MarkdownPP(input=mdpp, output=md, modules=modules)
  File "/usr/local/lib/python2.7/site-packages/MarkdownPP/MarkdownPP.py", line 28, in __init__
    pp.process()
  File "/usr/local/lib/python2.7/site-packages/MarkdownPP/Processor.py", line 49, in process
    transforms = module.transform(self.data)
  File "/usr/local/lib/python2.7/site-packages/MarkdownPP/Modules/TableOfContents.py", line 119, in transform
    TableOfContents.clean_title(title)).lower()
  File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)

Expected behaviour:

  • Unicode characters in headings should be allowed

Spurious character in Markdown?

This may well be something I am doing wrongly. I have some nested !INCLUDE which are correctly bringing in the content of the included files. However, the final Markdown isn't identifying the level one headers as such - they just appear as plain text. Upon closer inspection I can see that the first character on the line isn't the "#", it is actually what looks to be an invisible character with, I think, the hex code EF. That character is not in the included source MD file.

If I insert a blank line at the top of the source MD file, before the "#" then the EF character doesn't appear and the resultant Markdown works as expected. However, including a blank line in the including file (ie before the !INCLUDE) doesn't have the same effect.

The workaround is to add a blank line at the top of each MD file, but that feels a bit odd. As I said, I suspect I am missing something very obvious.

Thanks, Nick.

I can't Install markdown-pp

I'm working on Ubuntu16.04.
I follow the steps:

  • Install PIP: sudo apt-get install python-pip
  • Install MarkdownPP: pip install MarkdownPP.

There is no error information on my screen.
But when I try to use command markdown-pp, It tells me markdown-pp: command not found

I found there is a MarkdownPP folder: /home/work/.local/lib/python2.7/site-packages/MarkdownPP

I know nothing about python and pip.
Could you tell me why and how to install correctly?
Thanks.

Variables

I suggest implementing variables. There might be a header section where variables are defined:

product: GitHub

Then some way to reference in the MD doc, like {{product}}.

cannot exclude modules...

$ markdown-pp -o home.md -e includeurl home.mdpp
Traceback (most recent call last):
File "/usr/bin/markdown-pp", line 108, in
modules.remove(module)
AttributeError: 'dict_keys' object has no attribute 'remove'

Command execution

Hello,

Is it possible to execute commands and include the output of the console within a document using your pre-processor? If not, do you know any tool that allows to do this?

Thank you very much!

Templates

The !INCLUDE functionality is handy but a bit limited. It would be more functional if the Include module received parameters to fill in the file to be included. For example:

File: hello.mdpp

!INCLUDE "include.md" {world}

File: include.md

Hello, {{ arg0 }}!

Desired hello.md:

Hello, world!

A hacky alternative would be to use the IncludeURL module to include an address on localhost, listening with a server running Flask, which in turn generates a dynamic markdown file based on the included URL, but that seems like overkill.

I could work on a PR if there is interest in this. It could be part of the Include module, or create a different module with a !TEMPLATE directive or similar.

Can't download Images-Preview with YoutubeEmbed.py

Hi,

YoutubeEmbed.py has a problem

  1. regex allow ONLY HTTP-URL, but MUST HTTPS
  2. image download (_add_play_button-function) doesn't work on macOS (with installed request module) maybe I need another module, don't know..
youtube_url_re = re.compile('^!VIDEO\s+"https://www\.youtube\.com'
                            '/embed/([a-zA-Z0-9\-]*)"')
image_url = 'https://img.youtube.com/vi/%s/0.jpg' % url
video_url = 'https://www.youtube.com/watch?v=%s' % url

Needs new release for `INCLUDEURL` module.

I used the latest version of MardownPP on PIP, but the INCLUDEURL directive was not working. It did work when I installed the package from this repo.

Could you make a new release so that the INCLUDEURL module is available?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.