-
Notifications
You must be signed in to change notification settings - Fork 8
Miscellaneous improvements (will add more detail later) #26
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
Miscellaneous improvements (will add more detail later) #26
Conversation
Thank you @wlupton wlupton |
Thanks @codejamninja. I feel that there's some more discussion to have here. For example:
How best to handle? Should I create separate issues? |
@codejamninja, please see the sphinx-doc/sphinx#7796 discussion. There's a suggestion that this crash could be fixed on the sphinx-markdown-parser side. |
href = urllib.parse.urlunparse(r._replace(path = r.path[:-3] + ".html")) | ||
except: | ||
pass | ||
url_check = urllib.parse.urlparse(href) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wlupton the previous code added .html, is this redundant (does sphinx or other code add it automatically) or is the behaviour actually changed? Some of my projects depend on this behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a test with this input:
These should all work:
* See [this file](extensions.html) for more info
* See [this file](extensions.md) for more info
* See [this file](extensions) for more info
It's actually the first one that doesn't work (the other two do). It's not detected as a link at all. Is that expected?
But I guess this also needs testing where there's an explicit link to an HTML file outside the "sphinx domain"?
Update:
I'd missed that I had the following sphinx warning:
introduction.md:: WARNING: None:any reference target not found: extensions.html
So if this does need to work, it needs not to be an any
reference. Using a file:
URL should be sufficient to guarantee this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change it at all, what was wrong with the old version?
Note that I suggested (in Python-Markdown/markdown#977) that maybe we could tolerate having to write something like:
or (with post-processing, e.g.,
Thoughts? |
@wlupton regarding your AutoStructify changes, the python-markdown parser was never designed to work with AutoStructify, which is based on recommonmark. I wrote the python-markdown parser to mostly not need AutoStructify, since all the AutoStructify features are specific to recommonmark and basically are redundant with python-markdown. (I added special handling for mathjax here.) The only thing missing then is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you run the test suite against the current example page & output?
href = urllib.parse.urlunparse(r._replace(path = r.path[:-3] + ".html")) | ||
except: | ||
pass | ||
url_check = urllib.parse.urlparse(href) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change it at all, what was wrong with the old version?
@wlupton Your URL changes caused the test suite to fail (it generates a .md link instead of .html) so I've reverted for now. |
I’m going to publish a release soon. If we could get all stable changes in by the end of this week that would be great. |
Thanks for the feedback, and please note that I never expected this to be merged without discussion (see my original comment)! Without AutoStructify, how can you (in pure markdown) define the toc tree, or include automatically-generated code documentation? Note that the motivation behind the link changes was to allow links to things like python objects and methods. For example, with these changes this works (to refer to the
I may pick this up again at a later date (probably split into multiple PRs). |
@infinity0, the file |
Sphinx does this automatically from the heading structure in the rST syntax tree.
CommonMark and python-markdown are two entirely different parsers. AutoStructify was written for the former, not the latter. OTHO Let me give some more details: this project has a fairly messy history, and I just got into it a few months ago when I rewrote OTOH, I intended this current version of
OK great, please do file PRs! However in my personal opinion rST is superior to markdown in every way, I would suggest it's simply easier for everyone involved to just use sphinx's existing support for that sort of autdoc, based on rST syntax. I only contributed to this project because some other constraints require me to support both markdown and rST in the same sphinx project, and the existing other sphinx-md parsers didn't fit my requirements e.g. mathjax support. |
It's not a reimplementation, recommonmark is commonmark. I believe our |
@wlupton I would like to see that :) Is your work public somewhere? |
@FlorianLudwig, you can see my changes in https://github.com/BroadbandForum/sphinx-markdown-parser/tree/feature/misc-improvements. This PR was merged but a later commit (9fdf309) reverted the changes to the As part of getting all this working, I created PRs in several repos, most of which were not well-received and were not merged. I haven't (as yet) followed this up but will at some point rebase all my stuff against all the latest versions, take feedback into consideration, and have another go. Let me know if you'd like a full list of the affected repos and PRs. |
once everything is ready let me know and I will accept the changes and release an update |
This PR contains several proposed changes for discussion. I've also created some companion PRs in other projects, all as part of setting up a new "markdown-only" sphinx project. For reference, here are the other PRs:
AutoStructify
's second mechanism for using fenced code blocks for direct invocation of ReST directives (the only one of these PRs that's specifically needed bysphinx-markdown-parser
)My goal was to avoid writing any ReST (apart from the necessary directives to pull in code documentation).
Here's a summary of the proposed changes:
new_section()
- try to get theid
from the heading and, if found, use it as the anchor textstart_new_section()
- similarly try to getclass
from the heading and, if found, use it as theclasses
attributevisit_a()
- substantial rewrite based onCommonMarkParser.visit_link()
logicAutoStructify
- addauto_toc_tree_maxdepth
andauto_toc_tree_numbered
options (and the corresponding logic); also changes to match the updatedvisit_a()
and to explicitly ignore any link text when generating the ToC tree (otherwise the supplied text gets used, which you never want: you want the section names from the referenced files)Here's what my main page looks like (
.display-none
uses the aboveclasses
feature to enable CSS to hide the section; this seemed like the best compromise: you need a section to give toAutoStructify
but it looks bad if actually displayed in the HTML):Comments welcome. I'd be happy to make any suggested updates and/or split this into multiple PRs.