How do I do strikethrough (line-through) in asciidoc?
Asked Answered
H

4

39

How do I render a strikethrough (or line-through) in an adoc file?

Let's presume I want to write "That technology is -c-r-a-p- not perfect."

Hendecagon answered 6/8, 2016 at 12:28 Comment(0)
P
18

As per Ascii Doc manual, [line-through] is deprecated. You can test here.

Comment from Dan Allen

It's important to understand that line-through is just a CSS role. Therefore, it needs support from the stylesheet in order to appear as though it is working.

If I run the following through Asciidoctor (or Asciidoctor.js):

[.line-through]#strike#

I get:

<span class="line-through">strike</span>

The default stylesheet has a rule for this:

.line-through{text-decoration:line-through}

You would need to do the same.

It is possible to customize the HTML that is generated using custom templates (Asciidoctor.js supports Jade templates). In that case, you'd override the template for inline_quoted, check for the line-through role and produce either an <s> or, preferably, a <del> instead of the span.

Passionless answered 20/12, 2017 at 11:47 Comment(0)
M
44
That technology is [line-through]#crap# not perfect.
Macneil answered 7/8, 2016 at 13:15 Comment(0)
P
18

As per Ascii Doc manual, [line-through] is deprecated. You can test here.

Comment from Dan Allen

It's important to understand that line-through is just a CSS role. Therefore, it needs support from the stylesheet in order to appear as though it is working.

If I run the following through Asciidoctor (or Asciidoctor.js):

[.line-through]#strike#

I get:

<span class="line-through">strike</span>

The default stylesheet has a rule for this:

.line-through{text-decoration:line-through}

You would need to do the same.

It is possible to customize the HTML that is generated using custom templates (Asciidoctor.js supports Jade templates). In that case, you'd override the template for inline_quoted, check for the line-through role and produce either an <s> or, preferably, a <del> instead of the span.

Passionless answered 20/12, 2017 at 11:47 Comment(0)
L
8

If you're only targeting the HTML backend, you can insert HTML code verbatim via a passthrough context. This can be done inline by wrapping the parts in +++:

That technology is +++<del>+++crap+++</del>+++ not perfect.

This won't help you for PDF, DocBook XML, or other output formats, though.

Libre answered 2/6, 2020 at 11:22 Comment(2)
It would be helpful if you edited your question to provide some context and explanation of how this code answers the question.Underproduction
@Dragonthoughts: I've added a bit of explanation.Upholstery
K
3

If the output is intended for HTML you can pass HTML.

The <s> HTML element renders text with a strikethrough, or a line through it. Use the element to represent things that are no longer relevant or no longer accurate.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/s

To render as:

Example text.

use:

1. Pass inline:

Example +++<s>text</s>+++.

2. Pass-through macro:

Example pass:[<s>text</s>].

3. Pass block:

++++
Example <s>text</s>.
++++
Kurd answered 29/12, 2021 at 9:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.