Code Monkey home page Code Monkey logo

commonmark.py's People

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

commonmark.py's Issues

ImportError when used with Google App Engine

When I try to use the library with App Engine I get this error, if I put import CommonMark at the top:

ERROR    2016-08-26 14:04:59,126 wsgi.py:263] 
Traceback (most recent call last):
  File "/home/super/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/home/super/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/home/super/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/home/super/WebProjects/myapp/blog.py", line 3, in <module>
    from models import Post
  File "/home/super/WebProjects/myapp/models.py", line 1, in <module>
    import CommonMark
  File "/home/super/WebProjects/myapp/libs/CommonMark/__init__.py", line 4, in <module>
    from CommonMark.main import commonmark
  File "/home/super/WebProjects/myapp/libs/CommonMark/main.py", line 15, in <module>
    from CommonMark.dump import dumpAST, dumpJSON
  File "/home/super/WebProjects/myapp/libs/CommonMark/dump.py", line 3, in <module>
    from builtins import str
  File "/home/super/WebProjects/myapp/libs/builtins/__init__.py", line 8, in <module>
    from future.builtins import *
  File "/home/super/WebProjects/myapp/libs/future/builtins/__init__.py", line 10, in <module>
    from future.builtins.iterators import (filter, map, zip)
  File "/home/super/WebProjects/myapp/libs/future/builtins/iterators.py", line 43, in <module>
    from future.types import newrange as range
  File "/home/super/WebProjects/myapp/libs/future/types/__init__.py", line 243, in <module>
    from .newrange import newrange
  File "/home/super/WebProjects/myapp/libs/future/types/newrange.py", line 25, in <module>
    from future.backports.misc import count   # with step parameter on Py2.6
  File "/home/super/WebProjects/myapp/libs/future/backports/__init__.py", line 17, in <module>
    from .misc import (ceil,
  File "/home/super/WebProjects/myapp/libs/future/backports/misc.py", line 900, in <module>
    from subprocess import check_output
ImportError: cannot import name check_output
INFO     2016-08-26 14:04:59,140 module.py:788] default: "GET /blog/5822463824887808 HTTP/1.1" 500 -
INFO     2016-08-26 14:04:59,196 module.py:788] default: "GET /favicon.ico HTTP/1.1" 304 -

But, when I import CommonMark inside a method I get:

ERROR    2016-08-26 13:38:08,116 webapp2.py:1552] cannot import name check_output
Traceback (most recent call last):
  File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/home/super/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/home/super/WebProjects/myapp/blog.py", line 29, in get
    self.render('permalink.html', post=post, url=self.url)
  File "/home/super/WebProjects/myapp/handlers.py", line 33, in render
    self.write(self.render_str(template, **kw))
  File "/home/super/WebProjects/myapp/handlers.py", line 30, in render_str
    return render_str(template, **kw)
  File "/home/super/WebProjects/myapp/handlers.py", line 20, in render_str
    return t.render(kw)
  File "/home/super/google_appengine/lib/jinja2-2.6/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/super/WebProjects/myapp/templates/permalink.html", line 1, in top-level template code
    {% extends "base.html" %}
ImportError: cannot import name check_output
INFO     2016-08-26 13:38:08,186 module.py:788] default: "GET /blog/5822463824887808 HTTP/1.1" 500 228
INFO     2016-08-26 13:38:08,281 module.py:788] default: "GET /favicon.ico HTTP/1.1" 304 -

I am used to add other libraries to my App Engine projects as described in App Engine's installing a library document but this library causes these errors even though it is working with webapp2 outside App Engine!

Note: I am using App Engine Standard Environment

TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

Error Detail

I got a error:

Traceback (most recent call last):
  File "/home/civa/mycode.py", line 170, in __get_data
    content = CommonMark.commonmark(content)
  File "/usr/local/lib/python3.4/dist-packages/CommonMark/main.py", line 32, in commonmark
    ast = parser.parse(text)
  File "/usr/local/lib/python3.4/dist-packages/CommonMark/blocks.py", line 915, in parse
    self.incorporate_line(lines[i])
  File "/usr/local/lib/python3.4/dist-packages/CommonMark/blocks.py", line 850, in incorporate_line
    self.add_line()
  File "/usr/local/lib/python3.4/dist-packages/CommonMark/blocks.py", line 620, in add_line
    self.tip.string_content += (self.current_line[self.offset:] + '\n')
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

... when I render the following markdown content...

>     sometext
>


line1 - > + more than 5 space indent
line2 - > + no content
line3 - a empty line

Reference to js version:

http://spec.commonmark.org/dingus/?text=%3E%20%20%20%20%20sometext%0A%3E%0A%0Aanything%20else...

platform

  • CommonMark version is 0.6.4 on pypi.
  • Install with sudo -H pip3 install --no-binary wheel CommonMark
  • Python version: 3.4.3
  • OS: ubuntu 15.10

Thank you so :)

Pyup Safety check is flagging security vulnerabilities within commonmark 0.9.1

Pyup Safety (https://pyup.io/safety/) is flagging the following security vulnerabilities in commonmark (which blocks builds for those like us who use Safety as a build gate). The report appears to be referring to the spec version underlying commonmark itself.

safety report
checked  packages, using pyup.io's DB
---
-> commonmark, installed 0.9.1, affected <0.29.0, id 37115
Commonmark 0.29.0 requires cached-path-relative >= 1.0.2. This fixes a security vulnerability, but it's only in the dev dependencies.
--
-> commonmark, installed 0.9.1, affected <0.25.1, id 34313
Commonmark 0.25.1 fixes a dingus vulnerability.  Use an iframe and innerHTML to prevent `<script>` tags from executing. Dingus:  let preview show when query has `text=`.  Previously, these URLs opened the HTML pane first, but now that we have XSS protection (the iframe), it should be okay to open the preview pane first. * Dingus: don't print sourcepos attributes in HTML/AST view.
--

Math equations

Do you plan to support math equations, for example enclosed between $...$ or $$...$$? The CommonMark spec doesn't seem to support it, although there are discussions about it.

If the answer is no, is there any way for a third-party library to implement a parsing extension for CommonMark-py?

If the answer is still no, I guess a hackish workaround might be to parse a document manually right before passing it to CommonMark-py, replacing $y=x$ by $y=x$, and transforming the corresponding Code nodes by new Math nodes in the AST.

Incorrect end sourcepos for fenced code blocks

The end of the sourcepos is set incorrectly for fenced code blocks.

For the following example, the sourcepos is given as [[1, 1], [4, 1]] while I would have expected [[1, 1], [4, 3]]:

```
foo
1
```

It seems that the offset in the line is taken from the line preceding the closing code fence, while the line number itself is taken from the line of the code fence itself.

Notice that in the following examples the line offset changes depending on the number of characters in the preceding line:

>>> commonmark.Parser().parse('''```
foo
12345
```''').first_child.sourcepos
[[1, 1], [4, 5]]

>>> commonmark.Parser().parse('''```
foo
12   
```''').first_child.sourcepos
[[1, 1], [4, 2]]

Issue with HTML-looking tags

Hi,

I'm trying to process a text coming from StackExchange in Python. It seems to be ok, except that HTML-looking tags are gone when I run
html=commonmark.commonmark(s)
e.g.
s=<p><em>This is an <example></em>. <example2> <a href="[LINK]">test</a></p>
becomes
This is an . test

How can I fix this and have:
This is an <example>. <example2> test

Thanks!

Render plain text from AST

Similar to #63, I'm wondering if it would be in scope to add a plain-text renderer, which would generate nice looking plain text output from the AST.

I put together:

https://github.com/JoshData/commonmark-py-plaintext

This is different from CommonMark output: Links, for instance, are represented in a way that's understandable by people who don't know CommonMark, rather than in the -style notation. Other than that, it mostly just normalizes headings, indentation, etc. It could be revised to generate actual CommonMark.

I'd be glad to see this integrated into this project.

Output Markdown from AST

Is it within the project's scope to generate CommonMark from the AST? I'm looking for something that lets me programmatically assemble an AST and generate Markdown, e.g. for generating GitHub wikis. For example, if this were possible:

ast.append_child(blocks.CodeBlock("code"))

or even:

ast.append_child(parser.parse('```\ncode\n```'))

Then I could do:

>>> CommonMarkRenderer().render(ast)
[...]
```
code
```
[...]

Or perhaps this is something that would first have to be done in https://github.com/jgm/commonmark.js?

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Deciding the future of `commonmark.py`

Hi everyone, from Read the Docs we would like to open up the question about the future of commonmark.py. The landscape of Markdown in Python and Sphinx has changed a lot over the past 12 months, and in particular markdown-it-py by @chrisjsewell et al achieves a level of extensibility that is beyond what's possible with commonmark.py (see #106 (comment)). Similarly, MyST-Parser provides a broader feature set than what recommonmark offers.

As a result of the latter, and with the hope of optimizing efforts, a couple of months ago we decided to deprecate recommonmark in favor of MyST-Parser. Since commonmark.py has a similar status, we would also like to deprecate it - but given that the project has a richer history and it's also a lower level package, we would like to first ask the current maintainers their opinion.

@nikolas and @lu-zero are the ones that have been merging code to commonmark.py in recent years. There are a bunch of open bugs and pull requests that haven't received much attention, and the last release is from October 2019 (ah, the good old times without global pandemics). Nobody from Read the Docs plans to step in and address them, so we would like to offer two possibilities:

  • We find a new GitHub organization for the project, where the same or new maintainers can give it some love, or
  • We add a similar deprecation note than the one we placed on recommonmark README, and archive the repository here.

If there is no response or consensus in a reasonable time frame, the latter option wins, since anyone can fork the repository anyway. But we would like to give others the chance to speak up so the complete repository, with all the issues and pull request history, can be cleanly transferred.

Thoughts?

cc @ericholscher

Forking CommonMark-py?

I haven't put much time into upstream CommonMark compatibility on this repository, but in the meantime do you think it would be worth making this a more official fork of CommonMark-py, since that project doesn't seem to be going anywhere?

That way, we could start publishing these changes on pypi, something like: https://pypi.python.org/pypi/CommonMark2

Link Nodes do not have Sourcepos property.

I'd like to modify links within my markdown files when building a distribution and this would be easier if the Link nodes also contained the Soucepos property.

For example, given the markdown:

example = '''Check out this [link](another-page.md)'''

Outputs the AST:

[document]
	Title: 
	Info: 
	Destination: 
	Sourcepos: [[1, 1], [1, 38]]
	Info: 
	Literal: 
	Children:
		-> [document]
			-> Title: 
			-> Info: 
			-> Destination: 
			-> Sourcepos: [[1, 1], [1, 38]]
			-> Info: 
			-> Literal: 
			-> Children:
		-> [paragraph]
			-> Title: 
			-> Info: 
			-> Destination: 
			-> Sourcepos: [[1, 1], [1, 38]]
			-> String content: 
			-> Info: 
			-> Literal: 
			-> Children:
		-> [text]
			-> Title: 
			-> Info: 
			-> Destination: 
			-> Open: True
			-> Info: 
			-> Literal: Check out this 
			-> Children:
		-> [link]
			-> Info: 
			-> Destination: another-page.md
			-> Open: True
			-> Info: 
			-> Literal: 
			-> Children:
		-> [text]
			-> Title: 
			-> Info: 
			-> Destination: 
			-> Open: True
			-> Info: 
			-> Literal: link
			-> Children:
		-> [link]
			-> Info: 
			-> Destination: another-page.md
			-> Open: True
			-> Info: 
			-> Literal: 
			-> Children:
		-> [paragraph]
			-> Title: 
			-> Info: 
			-> Destination: 
			-> Sourcepos: [[1, 1], [1, 38]]
			-> String content: 
			-> Info: 
			-> Literal: 
			-> Children:
		-> [document]
			-> Title: 
			-> Info: 
			-> Destination: 
			-> Sourcepos: [[1, 1], [1, 38]]
			-> Info: 
			-> Literal: 
			-> Children:

My goal is to do something like:

walker = ast.walker()
for node, event in walker:
    if node.t == 'link':
        # grap the position of the link form the sourcepos.
        # strip the .md extension from the link
        # write out the modified file to the distribution.
        pass

I guess my question is, is there any reason why it doesn't? Or is there a better way to achieve my goal?

Thanks

Problem with options={'smart':True} and python3

When running on python3, integer division can give floats.
This gives a problem in https://github.com/rtfd/CommonMark-py/blob/master/CommonMark/inlines.py#L97 which now tries to multiply a string by a float.

  File "/usr/local/lib/python3.6/site-packages/CommonMark/inlines.py", line 98, in smart_dashes
    return ('\u2014' * em_count) + ('\u2013' * en_count)
TypeError: can't multiply sequence by non-int of type 'float'

The solution is to convert CommonMark.inlines.smart_dashes to use integer division (//) instead of true division (/). Adding from __future__ import division to the top of this file should also reveal this problem on python2. As far as I can tell, integer division is supported since python2.2.

Consider editing repository setings to remove "Packages" section

"Packages No packages published" is displayed right now, fortunately this pointless section can be removed.

Edit repo page config to remove it (cog next to the description).

I am not making a PR as it is defined in proprietary github settings, not in a git repository - and I have no rights to modify repo settings.

Peek 2020-10-25 09-10

Breaking change in 0.8.0 - "ImportError: No module named CommonMark"

Hi!

There was a breaking change in commonmark v0.8.0 (and also present in v0.8.1), that causes our sphinx+recommonmark build to fail:

Traceback (most recent call last):
  File "/home/travis/venv/lib/python2.7/site-packages/sphinx/config.py", line 161, in __init__
    execfile_(filename, config)
  File "/home/travis/venv/lib/python2.7/site-packages/sphinx/util/pycompat.py", line 150, in execfile_
    exec_(code, _globals)
  File "/home/travis/venv/lib/python2.7/site-packages/six.py", line 709, in exec_
    exec("""exec _code_ in _globs_, _locs_""")
  File "<string>", line 1, in <module>
  File "conf.py", line 2, in <module>
    from recommonmark.parser import CommonMarkParser
  File "/home/travis/venv/src/recommonmark/recommonmark/parser.py", line 9, in <module>
    from CommonMark import Parser
ImportError: No module named CommonMark

See:
https://travis-ci.org/mozilla/treeherder/jobs/425655351#L641

Our requirements file (that has now been pinned to commonmark 0.7.5, the last release that works with recommonmark master) is here:
https://github.com/mozilla/treeherder/blob/817ac227f3cd6b2dfeb049f853b68269552a2964/requirements/docs.txt

I believe this was due to #131.

Would it be possible to revert that PR, release a 0.8.2 that supports the old module name, and then remove the symlink in 1.0.0 instead? (I'll also file an issue against recommonmark for adding an upper bound on their range of <1 and/or adjusting their import)

Better API for humans

Having a simple API similar to markdown2:

>>> from CommonMark import commonmark
>>> commonmark("*boo!*")
'<p><em>boo!</em></p>\n'
>>> commonmark("*boo!*", format="json")
'{"last_line_blank": false, "open": false, "start_line": 1, "t": "Document", "tight": false, "end_line": 0, "children": [{"last_line_blank": false, "open": false, "start_line": 1, "t": "Paragraph", "inline_content": [{"last_line_blank": false, "open": true, "t": "Emph", "tight": false, "c": [{"last_line_blank": false, "open": true, "t": "Str", "tight": false, "c": "boo"}, {"last_line_blank": false, "open": true, "t": "Str", "tight": false, "c": "!"}]}], "tight": false, "strings": ["*boo!*"], "end_line": 0, "start_column": 1}], "start_column": 1}'

Do not hide link labels

Sorry but how can I not hide link labels? For instance

[foo][bar]
...
[bar]: http://foo.bar "foo bar"

is turned into a link, but I want to keep the foot reference visible. What happens is that they are hidden, not rendered in the output.

Nested list in markdown cannot convert to rst correctly

* abc
    - 123
    - 456
* def

should show as:

  • abc
    • 123
    • 456
  • def

But with the code:

def md2rst(lines):
    m = '\n'.join(lines)

    parser = commonmark.Parser()
    ast = parser.parse(m)

    renderer = commonmark.ReStructuredTextRenderer()
    rst = renderer.render(ast)

    lines[:] = rst.splitlines()

it cannot output the correct rst string.

The wheel file distributed has a spurious path

I am using macbook.
$sudo -H pip install commonmark

  $cmark.py -h
  -bash: /usr/local/bin/cmark.py: /home/nnyby/src/CommonMark-py/venv/bin/python: bad interpreter: No such file or directory

Do not escape HTML

How can I avoid HTML escaping? For example

**foo**
<div>
    **bar**
</div>

foo is emphasized but bar is not, and the <div> is escaped to &lt;div&gt;. I would like to leave the HTML as-is, and convert everything else.

Broken package on MacOS since 0.8.0

Hi,

#60 #131 seems to break the package installation/import on MacOS (10.13.6, APFS volume, homebrew python 2.7.10).

$ pip install commonmark==0.7.5
$ python
Python 2.7.10 (default, Oct  6 2017, 22:29:07)
>>> import CommonMark
>>> 

$ pip install commonmark==0.8.0
$ python
>>> import commonmark
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named commonmark
>>> import CommonMark
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alexandre/Developer/Etalab/udata/pyenv/lib/python2.7/site-packages/CommonMark/__init__.py", line 4, in <module>
    from commonmark.main import commonmark
ImportError: No module named commonmark.main

FYI the package is still installed under site-packages/CommonMark for me, but if I understand #131 correctly it should be under site-packages/commonmark?

Thanks!

Use an enumeration for the nodes' t

Currently, figuring out the available types a node can be requires either reading through the source code or trial and error. I would sugget using enum instead. If there's interest in this change, I could send a pull request, although I'm guessing this would be a breaking change.

Support for YAML front-matter

Currently, when getting the AST for a Markdown file with YAML front-matter, the content is not identified as such.

image

thematic_break is seen first, but after that the closing --- is not properly identified and is seen as part of the header.

Detach fork from parent repo to make this repo searchable

I noticed when trying to search in the code of this repo the following error message:

Sorry, forked repositories are not currently searchable.
You could try searching the parent repository.

Is it an option to detach from the parent repo in order to be able to search in the code of this repo on github?

pip install different from GitHub source, includes duplicate / old methods?

When trying to find the new syntax to set softbreak, I've run across the following issue.

  1. There are files in the pip install which are not in Github project source. For example, html.py
  2. These file contain possibly old, non-compatible code. For example html.py has
class HtmlRenderer(object):

    def __init__(self, options={}, softbreak='\n'):
        # by default, soft breaks are rendered as newlines in HTML.
        # set to "<br />" to make them hard breaks
        # set to " " if you want to ignore line wrapping in source
        self.softbreak = softbreak
        self.options = options
  1. This is really confusing, as there is an other (newer?) implementation in render/html.py, which says
class HtmlRenderer(Renderer):
    def __init__(self, options={}):
        #  by default, soft breaks are rendered as newlines in HTML
        options['softbreak'] = options.get('softbreak') or '\n'
        # set to "<br />" to make them hard breaks
        # set to " " if you want to ignore line wrapping in source

        self.disable_tags = 0
        self.last_out = '\n'
        self.options = options

I've deleted the old html.py and everything seems to be fine. This way I could actually debug my issue and find the new syntax for softbreak.

Can you make sure that the pip isn't installing any leftover, deprecated, non-used, etc. files?

Interface with pandoc

Hi, thanks for taking over this project!
I'm currently writing a pandoc-compatible Python library for converting markup documents. It implements a language-independent AST that is almost the same as pandoc's. For the markdown parser I'm considering using CommonMark-py (I'd rather use CommonMark rather than another Markdown parser). What I need to do is convert the CommonMark-py AST to the pandoc AST. I have a couple of questions in this respect:

  • It seems that Spaces are not detected like in pandoc? see e.g. the pandoc AST for hello world:
echo "hello world" | pandoc -f markdown -t json | python -m json.tool
[
    {
        "unMeta": {}
    },
    [
        {
            "t": "Para",
            "c": [
                {
                    "t": "Str",
                    "c": "hello"
                },
                {
                    "t": "Space",
                    "c": []
                },
                {
                    "t": "Str",
                    "c": "world"
                }
            ]
        }
    ]
]

To be compared with CommonMark-py (stripped-down output):

{
    "t": "Document",
    "children": [
        {
            "inline_content": [
                {
                    "c": "hello world",
                    "t": "Str"
                }
            ],
            "t": "Paragraph",
            "strings": [
                "hello world"
            ]
        }
    ]
}

Is it intended for CommonMark not to explicitly parse spaces?

  • It seems like the internal tree representation in CommonMark is still changing (which I totally understand as this project seems to be a work-in-progress, so is my library). Is there a plan to make this representation stable and public in the future? If not, what would be the most sensible way for me to take the CommonMark AST and convert it to the pandoc AST? You can have a look at how I've done it so far. It only works on the latest pip version, not master, as it seems like node.children has disappeared.

nested emphasis and strong tags when phrase ends in colon

The following code results in a nested <strong> tag:

import commonmark
parser = commonmark.Parser()
renderer = commonmark.HtmlRenderer()

test = "normal**bold:**normal normal**bold bold**normal"
renderer.render(parser.parse(test))
# '<p>normal<strong>bold:<strong>normal normal</strong>bold bold</strong>normal</p>\n'

Using a single asterisk results in identical behavior but with nested <em> tags. Underscores aren't converted.

The following input behaves differently:

'normal**bold:**normal normal'

Which yields:

'<p>normal**bold:**normal normal</p>\n'

The combination of a colon, no space, and another bold item seems to result in this behaviour, as the following inputs behave as expected:

'normal**bold**normal normal**bold bold**normal'
'normal**bold:** normal normal**bold bold**normal'

Yield:

'<p>normal<strong>bold</strong>normal normal<strong>bold bold</strong>normal</p>\n'
'<p>normal<strong>bold:</strong> normal normal<strong>bold bold</strong>normal</p>\n'

I'm using python 3.7.2 with commonmark 0.8.1 (conda-forge distribution)

Package name is not PEP 8 compliant

I realize that there are already many users of the package, but is there any possibility of the package's name being made to be PEP 8 compliant (and also match the js version)? It's a small issue but I'd much rather be looking at import commonmark than import CommonMark in my code.

Understanding of JSON output

Hi all,

I try to get JSON output using this library.

I tried the Python library and the cmark command line tool with the same results. HTML and AST looks ok for me:

cmark  <<< '*hello!*'
<p><em>hello!</em></p>
cmark -a <<< '*hello!*'
[document]
    Title:
    Info:
    Destination:
    Sourcepos: [[1, 1], [1, 8]]
    Info:
    Literal:
    Children:
        -> [document]
            -> Title:
            -> Info:
...

But I do not understand the JSON output:

cmark -aj <<< '*hello!*'
{"is_fenced": false, "t": "document", "sourcepos": [[1, 1], [1, 8]], "fence_length": 0, "open": false, "last_line_blank": false}

Honestly, I have no idea what this all about...

I expect some like this:

[ "paragraph" , [
  [ "emph" , {} , [
    [ "text" , {} , [ "hello"
...

Can you give me some hints what I am oing wrong?

Regards,
Reto

Treat AST node names as a public interface when bumping package version number

I work on a project that integrates closely with the CommonMark library. Specifically, I need to read Markdown as an AST instead of dumping it right to HTML.

I got a working implementation without too much trouble based on 0.6.3, but in 0.6.4, you renamed all your AST nodes, breaking my code! This is not something I would expect in an 0.0.x release.

You've probably been thinking of the AST as an internal interface, but it's so incredibly useful to people like me who want to use all that information. If you make changes on the same level in a future release, please bump at least the 0.x version so I can write a setup.py rule that makes sense.

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.