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

skip contents in <pre></pre> #38

Closed
hathach opened this issue Jun 26, 2014 · 6 comments
Closed

skip contents in <pre></pre> #38

hathach opened this issue Jun 26, 2014 · 6 comments
Assignees
Labels

Comments

@hathach
Copy link

hathach commented Jun 26, 2014

some of my text in

 <\pre> tag accidentally follows an header syntax, is it possible to skip those

@thlorenz
Copy link
Owner

Thanks for reporting this and yes it's possible to fix this.
My time is limited currently though, so PRs with tests are very welcome :)

BTW a related issue exists.

@thlorenz thlorenz added the bug label Jun 26, 2014
@thlorenz thlorenz self-assigned this Jun 26, 2014
@hathach
Copy link
Author

hathach commented Jun 26, 2014

Table of Contents generated with DocToc

Header 1

Header 2

False Heading 1
------------------------
 
some text
Failed Heading 2
================================================
 
Yet another text

@hathach
Copy link
Author

hathach commented Jun 26, 2014

Thanks for the link and a quick response, above post is a simple test and the generated TOC by doctoc

@thlorenz
Copy link
Owner

Thanks for the test case.
I was more hoping for something along the lines of implementing a test in the repo then fixing the issue and pull requesting with that.

That is if you are interested to take this on and have the time. Otherwise I'll look into it once I have some bandwidth.

@hathach
Copy link
Author

hathach commented Jun 27, 2014

I would love to help, however, I have no idea as well knowledge of your project. My main field is embedded system. Your project is extremely helpful and useful. bravo :)

yomed added a commit to yomed/doctoc that referenced this issue Aug 22, 2015
Anthropic added a commit to Anthropic/doctoc that referenced this issue May 29, 2016
jez added a commit to jez/doctoc that referenced this issue May 30, 2016
Both of these tests should be fixed before we can consider thlorenz#37, thlorenz#38,
and thlorenz#88 as resolved.

Credit goes to @yomed for `test/fixtures/readme-with-code.md`.
jez added a commit to jez/doctoc that referenced this issue May 30, 2016
Fixes thlorenz#37, thlorenz#38, thlorenz#88.

This commit builds upon the markdown-to-ast integration we added in thlorenz#91,
using markdown-to-ast in `lib/get-html-headers.js`.

We first filter our lines to only look for HTML sections (using the
markdown parser), then in these HTML-only sections, we search for
headers, as long as they're not inside pre tags.

This is accomplished by keeping a stack of tags we've descended through.
We can peek at the top of the stack to see if we're directly under a
`pre` tag, meaning we should ignore everything until we see the closing
`pre`. Otherwise, we can collect text from inside heading tags as
normal.

Thus, the core changes in this commit are:

- `grabbing` is a stack now, instead of a string
- `markdown-to-ast` lets us filter for only HTML blocks
- `htmlparser2` lets us check if we're inside a heading *or* pre tag
jez added a commit to jez/doctoc that referenced this issue May 30, 2016
Fixes thlorenz#37, thlorenz#38, thlorenz#84, thlorenz#88.

This commit builds upon the markdown-to-ast integration we added in thlorenz#91,
using markdown-to-ast in `lib/get-html-headers.js`.

We first filter our lines to only look for HTML sections (using the
markdown parser), then in these HTML-only sections, we search for
headers, as long as they're not inside pre tags.

This is accomplished by keeping a stack of tags we've descended through.
We can peek at the top of the stack to see if we're directly under a
`pre` tag, meaning we should ignore everything until we see the closing
`pre`. Otherwise, we can collect text from inside heading tags as
normal.

Thus, the core changes in this commit are:

- `grabbing` is a stack now, instead of a string
- `markdown-to-ast` lets us filter for only HTML blocks
- `htmlparser2` lets us check if we're inside a heading *or* pre tag
jez added a commit to jez/doctoc that referenced this issue May 30, 2016
Fixes thlorenz#37, thlorenz#38, thlorenz#84, thlorenz#88, thlorenz#99.

This commit builds upon the markdown-to-ast integration we added in thlorenz#91,
using markdown-to-ast in `lib/get-html-headers.js`.

We first filter our lines to only look for HTML sections (using the
markdown parser), then in these HTML-only sections, we search for
headers, as long as they're not inside pre tags.

This is accomplished by keeping a stack of tags we've descended through.
We can peek at the top of the stack to see if we're directly under a
`pre` tag, meaning we should ignore everything until we see the closing
`pre`. Otherwise, we can collect text from inside heading tags as
normal.

Thus, the core changes in this commit are:

- `grabbing` is a stack now, instead of a string
- `markdown-to-ast` lets us filter for only HTML blocks
- `htmlparser2` lets us check if we're inside a heading *or* pre tag
@jez
Copy link
Collaborator

jez commented Jun 1, 2016

Closed via #107.

@jez jez closed this as completed Jun 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants