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

Generalize synopsis role #599

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions adoc/config/khronos.css
Original file line number Diff line number Diff line change
Expand Up @@ -483,20 +483,20 @@ pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
.listingblock.terminal pre .command:not([data-prompt]):before { content: "$"; }

/* Format "[source,role=synopsis]" blocks. This format overrides "listingblock" above. */
.synopsis > .content {
.listingblock.synopsis > .content {
position: relative;
display: inline-block;
border: 1px solid #ddd;
}
.synopsis pre, .synopsis pre[class] {
.listingblock.synopsis pre, .listingblock.synopsis pre[class] {
padding: 7px 7px 7px 7px;
}

/* Any "[source,role=synopsis]" blocks with an "id" have an anchor tag inside the
/* Any "[role=synopsis]" blocks with an "id" have an anchor tag inside the
block's <div>. (See the "synopsis" Ruby extension script.) Style this as a
pound sign in the left column that is visible when hovering over the listing
block. This is similar to the way section headers are styled, but with a
pound sign instead of a section sign.
pound sign in the left column that is visible when hovering over the block.
This is similar to the way section headers are styled, but with a pound sign
instead of a section sign.
*/
.synopsis > a {
position: absolute;
Expand Down
21 changes: 6 additions & 15 deletions adoc/config/synopsis/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,21 @@

include ::Asciidoctor

# Add HTML anchors for "[source,role=synopsis,id=X]" blocks, changing the HTML
# from this:
# Add HTML anchors for "[role=synopsis,id=X]" blocks, changing the HTML from
# this:
#
# <div id="X" class="listingblock synopsis">
# <div id="X" class="XX synopsis">
#
# to this:
#
# <div id="X" class="listingblock synopsis">
# <div id="X" class="XX synopsis">
# <a href="#X"></a>
#
# Note that this happens only if the block has an "id" attribute.
#
# This extension also relies on some custom CSS styling to turn the anchor into
# into a section marker that you can click on to get the URL of the synopsis
# block. See the CSS entries for the class name "synopsis".
#
# TODO: It would be nice to create a custom Asciidoc block instead of using the
# "role=" syntax. This would allow the Asciidoc source to look like:
#
# [synopsis,id=X]
#
# However, doing this disables the source code highlighting feature. I think
# this is because the rouge highlighter looks only at [source] blocks, and I
# cannot find a way to tell it to look at a custom block named [synopsis].
# into a marker that you can click on to get the URL of the synopsis block. See
# the CSS entries for the class name "synopsis".

class AddSynopsisAnchors < Extensions::Postprocessor

Expand Down