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

enh(asciidoc) Support level 5 sections #2903

Merged
merged 4 commits into from
Dec 3, 2020
Merged

enh(asciidoc) Support level 5 sections #2903

merged 4 commits into from
Dec 3, 2020

Conversation

il3ven
Copy link
Contributor

@il3ven il3ven commented Dec 3, 2020

Resolves #2868

Changes

Updated regexp for sections in src/languages/asciidoc.js

Before

begin: '^(={1,5}) .+?( \\1)?$'

After

begin: '^(={1,6})[ \t].+?([ \t]\\1)?$'
  1. Section titles can contain ====== that is why changed (={1,5}) to (={1,6})
  2. A = can be followed by a space or a tab. So, added [ \t].

Changes are based upon https://github.com/asciidoctor/asciidoctor/blob/697d7171830f3dc757175bc29b7eb528d4cdb4b5/lib/asciidoctor/rx.rb#L239

Checklist

  • Added markup tests, or they don't apply here because...
  • Updated the changelog at CHANGES.md
  • Added myself to AUTHORS.txt, under Contributors

@joshgoebel
Copy link
Member

joshgoebel commented Dec 3, 2020

I'm confused the site you linked to has (=={0,5}) and seems to indicate == is Level 1... oh I see they call = level 0. Ugh.

I'm not sure why they have the 0... since is a line really a title without any ====? But given their rule it would seem that

========== (== * 5)

Is also a possibility, no?

@joshgoebel
Copy link
Member

The examples on their doc site seem to contradict the whole =={0,5} also... so frustrating.

@joshgoebel joshgoebel changed the title fix(asciidoc) Updated regexp for sections enh(asciidoc) Updated regexp for sections Dec 3, 2020
@joshgoebel joshgoebel changed the title enh(asciidoc) Updated regexp for sections enh(asciidoc) Support level 5 sections Dec 3, 2020
@joshgoebel joshgoebel merged commit c0b6ddb into highlightjs:master Dec 3, 2020
@il3ven
Copy link
Contributor Author

il3ven commented Dec 3, 2020

========== (== * 5) Is also a possibility, no?

No.

I think the regular expression =={0,5} means that after a = there can be 0 to 5 = signs.

====== is a valid section as in this case = is followed by 5 =. However, ======= is not a valid section as the = is followed by 6 =.

I think a reason they used =={0,5} instead of ={1,6} is to differentiate sections from document title.

= Document Title (Contains a single = )

@ggrossetie
Copy link
Contributor

Thanks @il3ven for taking care of it.

You got it right.
= Document Title is a document title not a section title.

The examples on their doc site seem to contradict the whole =={0,5} also... so frustrating.

It's two equal signs (==) followed by 0 up to 5 equal signs.
So effectively between == (2 equal signs) and ====== (6 equal signs).

@joshgoebel
Copy link
Member

joshgoebel commented Dec 4, 2020

I think the regular expression =={0,5} means that after a = there can be 0 to 5 = signs.

It totally does, and I know that. To group the == you'd need (==) of course. That whole == is just infuriating and confusing and totally throwing me off. :-)

I think a reason they used =={0,5} instead of ={1,6} is to differentiate sections from document title.

=={0,5} and ={1,6} have exactly the same behavior. I can't see any reason to prefer == so I have no idea why they chose to write it that way.

= Document Title is a document title not a section title.

I don't think we care, it'll still match as a "section" for us, no?

It's two equal signs (==) followed by 0 up to 5 equal signs. So effectively between == (2 equal signs) and ====== (6 equal signs).

Nope.

=                 A single = 
={0,5}          0 to 5 =s

A single equal, followed by 0-5 more... otherwise known to normal people as "1-6 equals" LOL.

So = would match.

@ggrossetie
Copy link
Contributor

Ah ah ah I got tricked 😬

So = would match.

On second thought, you can have section title level 0 (i.e., a single =) when using a book doctype.
Maybe the reasoning was to match the AsciiDoc definition, you can have level 0 to level 5 section titles.

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.

(asciidoc) Section titles level 5 (i.e. using 6 "=" characters)
3 participants