Skip to content

[feature] New attribute for highlight shortcode to allow span tag like inline but syntax highlighted code #9442

@kaushalmodi

Description

@kaushalmodi

Right now, if I have this in the markdown:

I am attempting to inline
{{< highlight emacs "linenos=inline" >}}(message "this highlight shortcode"){{< /highlight >}}.
But it is creating a paragraph break around it.

it renders to:

image

This issue is to request a feature addition to the highlight shortcode with a boolean attribute like inline, where if inline=true is set, it will render span tags instead of div tags and remove the pre tags.

With a shortcode "hl4.html" defined this way:

{{- transform.Highlight .Inner (.Get 0) (.Get 1 | default "")
    | replaceRE `^<div class="highlight"><pre [^>]+>((.|\n)+)</pre></div>$`
                `<span class="highlight-inline chroma">${1}</span>`
    | safeHTML -}}

and this in the markdown:

I am attempting to inline
{{< hl4 emacs >}}(message "this hl4 shortcode"){{< /hl4>}}. And this!! finally works.

we can get this:

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions