Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing to compile MarkDown posts from string to string. #2622

Merged
merged 4 commits into from Jan 8, 2017

Conversation

felixfontein
Copy link
Contributor

Allows to compile MarkDown from string to string (for getnikola/plugins#201).

felixfontein added a commit to getnikola/plugins that referenced this pull request Jan 8, 2017
@@ -63,6 +63,15 @@ def set_site(self, site):

self.config_dependencies.append(str(sorted(site.config.get("MARKDOWN_EXTENSIONS"))))

def compile_to_string(self, content):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But please match the reST plugin API.

    def compile_string(self, data, source_path=None, is_two_file=True):
        """Compile Markdown into HTML strings."""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if markdown is None:
req_missing(['markdown'], 'build this site (compile Markdown)')
self.extensions += self.site.config.get("MARKDOWN_EXTENSIONS")
if not is_two_file:
_, content = self.split_metadata(content)
output = markdown(content, self.extensions, output_format="html5")
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source, with_dependencies=True, extra_context=dict(post=post))
output, shortcode_deps = self.site.apply_shortcodes(output, filename=source_path, with_dependencies=True, extra_context={'post': post})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing that!

@Kwpolska Kwpolska merged commit 80abb4a into master Jan 8, 2017
@Kwpolska Kwpolska deleted the markdown-to-string branch January 8, 2017 11:50
@felixfontein
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants