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

Provide ability to disable prettify code highlighting #64

Merged
merged 1 commit into from
Nov 21, 2016

Conversation

jonas
Copy link
Contributor

@jonas jonas commented Nov 21, 2016

Either using:

```nocode
...
```

or for snippets:

@@ snip [apache.log](apache.log) { type=nocode }

As discussed in lightbend/ssl-config#51 Paradox will eagerly highlight anything inside fenched code block. This PR provides an escape hatch for this behaviour.

@@ -65,5 +65,8 @@ abstract class StyledVerbatimSerializer extends VerbatimSerializer {
*/
object PrettifyVerbatimSerializer extends StyledVerbatimSerializer {
override def printPreAttributes(printer: Printer): Unit = printClass(printer, "prettyprint")
override def printCodeAttributes(printer: Printer, nodeType: String): Unit = printClass(printer, s"language-$nodeType")
override def printCodeAttributes(printer: Printer, nodeType: String): Unit = nodeType match {
case "nocode" => printClass(printer, s"nocode")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prettify uses nocode, I am open to suggestions for a better name.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

```text
foo
```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prettify will still try to highlight it. nocode is the only way to turn off this behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we pass "nocode" to Prettify when the user types in ```text in addition to nocode?

Copy link
Contributor Author

@jonas jonas Nov 21, 2016

Choose a reason for hiding this comment

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

Example:

screen shot 2016-11-21 at 2 19 45 pm

Yes, I can update to pass nocode when type is text (in addition to nocode)

@jonas
Copy link
Contributor Author

jonas commented Nov 21, 2016

Updated to both map text and nocode.

The alternative would be to always add the nocode class when no node type is defined.

Either using:

    ```text
    ...
    ```

or for snippets:

    @@ snip [apache.log](apache.log) { type=text }
@jonas
Copy link
Contributor Author

jonas commented Nov 21, 2016

Rebased and added notes entry

@dwijnand
Copy link
Member

This at least is where we can mirror and match GHM, so we should pick
whatever works in native GHM to indicate "plain text, don't highlight". I
expect there are a number of alternatives.

On Mon, 21 Nov 2016, 20:12 Jonas Fonseca, notifications@github.com wrote:

Rebased and added notes entry


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#64 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAVCIkuRjj1mbGStLHvw4vsbKi_F7Vjrks5rAftGgaJpZM4K4cum
.

@eed3si9n
Copy link
Contributor

@dwijnand I'm guessing that Kramdown / Redcarpet or whatever that implements GFM uses ``` to indicate plain text without special postfix. We can deal with flipping the default behavior of ``` in another PR, but having a way to force plain text for now is a useful workaround that doesn't require changing all existing text.

https://help.github.com/articles/creating-and-highlighting-code-blocks/

@eed3si9n eed3si9n merged commit c0e8bb7 into lightbend:master Nov 21, 2016
@dwijnand
Copy link
Member

Linguist I believe is the tool to categorise languages and I assumed it had
an identifier for plain text. I wasn't implying changing every code snippet.

On Mon, 21 Nov 2016, 21:54 eugene yokota, notifications@github.com wrote:

Merged #64 #64.


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#64 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAVCIjinkvpUiwUV2XkHNZWThfpfTeHXks5rAhMkgaJpZM4K4cum
.

@jonas jonas deleted the nocode branch November 21, 2016 23:14
@sirthias
Copy link
Contributor

In addition to the per-snippet solution proposed here I think it'd be great if paradox also offered a way to completely disable the existing strong coupling with google-code-prettify. In my project for example we use highlight.js instead, which doesn't require class="prettyprint" attributes on pre elements.

IMHO paradox should offer an SBT setting that allows users to completely switch off any generation-time highlighting support.

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.

4 participants