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

URL are changed in <script src> from code blocks #240

Closed
Toilal opened this issue Nov 26, 2014 · 8 comments
Closed

URL are changed in <script src> from code blocks #240

Toilal opened this issue Nov 26, 2014 · 8 comments
Milestone

Comments

@Toilal
Copy link

@Toilal Toilal commented Nov 26, 2014

I face a really strange issue.

Please see this file, and notice in Install Manually section, step 4, in the sample code.

<script src="assets/angular-gantt.js"></script>

When i generate the docs using mkdocs build, it gives the following page, and the script source is changed :

<script src="../assets/angular-gantt.js"></script>

Notice the ../ added to the begining of file. This may have sense for real <script src...> tag, but it should not occur inside a code block (4-space indent or quoted)

Page generated by readthedocs has the same issue.

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Nov 26, 2014

ah, I know why that is happening. I think it is being detected as an image, so we re-write the path as if the images are in the root.

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Nov 26, 2014

So, this happens, because we need to correct the path to images as the "location" changes from a file getting-started.md to a directory getting-started/ so the reference needs to be moved. However, we should not touch anything inside a code block. So, essentially, these regular expressions are far too naive: https://github.com/tomchristie/mkdocs/blob/master/mkdocs/build.py#L79-L87

We peobably need to change to a tool that understand HTML structure. Using regexes for this is a bad idea.

@Toilal
Copy link
Author

@Toilal Toilal commented Nov 26, 2014

I've commented your commit for a better regexp. But for sure, it should not be regexp here, as code blocks should be totally exluded.

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Nov 26, 2014

Yeah, I just hacked that together to check it fixed the problem I'll try and figure out a more robust solution.

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Nov 26, 2014

Fixing something like this would be really easy with pyquery but it is quite a heavyweight dependency. Thoughts @tomchristie ?

@tomchristie
Copy link
Contributor

@tomchristie tomchristie commented Nov 26, 2014

Lukewarm in that, at least right now.

I'd have thought than a markdown extension (ie we have some parsing info available to us) might be another option maybe?

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Nov 26, 2014

Hmm, true. If nothing else, processing the markdown would be easier than the HTML. I'll look into an extension.

@SvenDowideit
Copy link

@SvenDowideit SvenDowideit commented Nov 27, 2014

yes, iirc, I made some change to this in the docker version - as relative URL's are mostly not useful in our context.

d0ugal added a commit to d0ugal/mkdocs that referenced this issue Nov 27, 2014
Use a Markdown extension to hook into the build process and modify the
HTML document tree rather than using regular expressions to process
the HTML.

Fixes mkdocs#240
d0ugal added a commit to d0ugal/mkdocs that referenced this issue Nov 28, 2014
@d0ugal d0ugal closed this in #250 Nov 28, 2014
@d0ugal d0ugal added this to the 0.12.0 milestone Dec 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants