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

[BUG] Code block wikitext syntax does not support css classes #8811

Open
rougsig opened this issue Dec 9, 2024 · 3 comments
Open

[BUG] Code block wikitext syntax does not support css classes #8811

rougsig opened this issue Dec 9, 2024 · 3 comments

Comments

@rougsig
Copy link

rougsig commented Dec 9, 2024

Describe the bug

Given (read ''' as ```):

'''.css-class
My perfect code
'''

Actual:

<p><code>`.css-class
My perfect code
</code><code></code></p>

Expected:

<pre class="css-class"><code>My perfect code</code></pre>

$tw.wiki.parseText outputs that:

[
  {
    "children": [
      {
        "children": [
          {
            "end": 32,
            "start": 2,
            "text": "\`.css-class
My perfect code
",
            "type": "text",
          },
        ],
        "end": 32,
        "rule": "codeinline",
        "start": 0,
        "tag": "code",
        "type": "element",
      },
      {
        "children": [
          {
            "end": 33,
            "start": 33,
            "text": "",
            "type": "text",
          },
        ],
        "end": 33,
        "rule": "codeinline",
        "start": 32,
        "tag": "code",
        "type": "element",
      },
    ],
    "end": 33,
    "start": 0,
    "tag": "p",
    "type": "element",
  },
]

TiddlyWiki Configuration

Render was checked on https://tiddlywiki.com/

@rougsig
Copy link
Author

rougsig commented Dec 9, 2024

Also no information about codeinline on the wiki.

I check that and that

@Jermolene Jermolene changed the title [BUG] codeblock does not support css classes (codeinline rule used) [BUG] Code block wikitext syntax does not support css classes Dec 10, 2024
@Jermolene
Copy link
Member

Hi @rougsig you are correct that the wikitext code block syntax does not allow CSS classes to be specified, and that attempting to do so will trigger the wikitext inline code syntax rule.

There might be confusion because the wikitext code block syntax does permit a language abbreviation to be specified with a very similar syntax:

 ```css
 body {
   color: red;
 }
 ```

I would expect that most applications for this could be satisfied with the @@ syntax by adding the appropriate CSS rules to the styles:

@@.myclass
* Block content
* With one assigned class
@@

@rougsig
Copy link
Author

rougsig commented Dec 10, 2024

Yes, that's true. Just a little confusing. I assumed all block statements had a css className property.

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

No branches or pull requests

2 participants