Skip to content
Open
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
9 changes: 3 additions & 6 deletions src/asciidoc/templates/Listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const Listing = ({ node }: { node: LiteralBlock }) => {
const { document } = useConverterContext()

const docAttrs = document.attributes || {}
const nowrap = node.attributes.nowrap || docAttrs['prewrap'] === undefined

if (node.style === 'source') {
const lang = node.language
Expand All @@ -19,7 +18,7 @@ const Listing = ({ node }: { node: LiteralBlock }) => {
>
<Title text={node.title} />
<div className="content">
<pre className={cn('highlight', nowrap ? ' nowrap' : '')}>
<pre className={cn('highlight', node.noWrap ? ' nowrap' : '')}>
{lang ? (
<code
className={lang ? `language-${lang}` : ''}
Expand All @@ -45,10 +44,8 @@ const Listing = ({ node }: { node: LiteralBlock }) => {
<Title text={node.title} />
<div className="content">
<pre
className={cn('highlight !block', nowrap ? 'nowrap' : '')}
dangerouslySetInnerHTML={{
__html: node.content || '',
}}
className={cn('highlight !block', node.noWrap ? 'nowrap' : '')}
dangerouslySetInnerHTML={{ __html: node.content || '' }}
/>
</div>
</div>
Expand Down
11 changes: 6 additions & 5 deletions src/asciidoc/utils/prepareDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export interface LiteralBlock extends BaseBlock {
type: 'listing'
source: string
language: string | undefined
decodedContent: string
noWrap: boolean
}

export interface SectionBlock extends BaseBlock {
Expand Down Expand Up @@ -325,14 +327,13 @@ export const prepareDocument = (document: AdocTypes.Document) => {
}

if (type === 'listing' || type === 'literal') {
const listingBlock = processedBlock as LiteralBlock
if ('getSource' in block) {
const listingBlock = processedBlock as LiteralBlock
listingBlock.source = block.getSource()
listingBlock.language = block.getAttribute('language')
listingBlock.content = listingBlock.content
? decode(listingBlock.content)
: undefined
}
listingBlock.noWrap = block.isOption('nowrap')
listingBlock.language = block.getAttribute('language')
listingBlock.decodedContent = decode(listingBlock.content)
}

if (type === 'section') {
Expand Down
5 changes: 5 additions & 0 deletions src/examples/listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public class ApplicationConfigurationProvider extends HttpConfigurationProvider
}
}
----

// html tags
----
MPN1:<MFG>:<PN>:<REV>:<SERIAL>
----
`

export default listing