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

resolves #342 replace pattern with generated code (no substitution) #343

Merged

Conversation

ggrossetie
Copy link
Member

resolves #342

@obilodeau
Copy link
Member

It would be nice to have something failing Travis that is fixed by that commit. To avoid regressions.

@ggrossetie
Copy link
Member Author

If we want to make sure that client-side syntax highlighting is working then we need to open the HTML page in a browser and check that code block is highlighted.
If you want I can add an "integration" test based on Puppeteer? We could also use this approach when slides are generated using Ruby.

Another option is to invoke asciidoctor-doctest from the JavaScript toolchain: #144
I did give it a try last year but I couldn't figure out how to plug Asciidoctor.js...

@obilodeau
Copy link
Member

Testing strategy

Another would be to diff the resulting converted examples from node to the ruby ones.

I did an initial attempt at this:

$ wdiff -3 examples/release-4.0.html release-4.0.html

======================================================================
 [-charset="utf-8" /><meta-] {+charset="utf-8"><meta+}
======================================================================
 [-minimal-ui" /><title>Asciidoctor-] {+minimal-ui"><title>Asciidoctor+}
======================================================================
 [-href="reveal.js/css/reset.css" /><link-] {+href="reveal.js/css/reset.css"><link+}
======================================================================
 [-href="reveal.js/css/reveal.css" /><link-] {+href="reveal.js/css/reveal.css"><link+}
======================================================================
 [-id="theme" /><!--This-] {+id="theme"><!--This+}
======================================================================
 [-href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-1/css/all.min.css" /><link-] {+href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-1/css/all.min.css"><link+}
======================================================================
 [-href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-1/css/v4-shims.min.css" /><!--Printing-] {+href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-1/css/v4-shims.min.css"><!--Printing+}
======================================================================
 [-href="release-4.0.css" /></head><body><div-] {+href="release-4.0.css"></head><body><div+}
======================================================================
 [-logo" /></div>-] {+logo"></div>+}
======================================================================

The only differences are how some tags are closed differently. Being pragmatic, until we have proper doctest, this can be removed:

$ diff -u <(sed 's/ //g;s/\///g' examples/release-4.0.html) <(sed 's/ //g;s/\///g' release-4.0.html) 
$ echo $?
0

Do you think this idea is worth pursuing? I don't have time to pursue a Puppeteer approach nor implement doctest for the Javascript toolchain. But a rake task that does this seems easy to achieve and would have caught that bug.

Anyways, I created issue #345.

Back to the PR

I tried it, it works. I'm going to merge this now.

Copy link
Member

@obilodeau obilodeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and it works!

@obilodeau obilodeau merged commit 716e877 into asciidoctor:master Feb 18, 2020
@ggrossetie
Copy link
Member Author

Being pragmatic, until we have proper doctest...

It's a good compromise for now 👍

@ggrossetie ggrossetie deleted the issue-342-replace-without-sub branch February 18, 2020 14:47
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.

Broken syntax highlighting on master with node
2 participants