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

Migrate to new AsciiDoc renderer #95

Merged
merged 13 commits into from
Dec 17, 2024
Merged

Conversation

benjaminleonard
Copy link
Collaborator

Following suit from docs and marketing site updates.

Also now using a bunch of shared AsciiDoc handling stuff from the design system to reduce duplication across the sites. Specifically on processing / handling / syntax highlighting.

Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
rfd-site ✅ Ready (Inspect) Visit Preview Dec 17, 2024 0:33am

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has totally checked 139 files.

Valid Invalid Ignored Fixed
86 2 51 0
Click to see the invalid file list
  • app/components/AsciidocBlocks/Footnotes.tsx
  • app/utils/asciidoctor.tsx

app/components/AsciidocBlocks/Footnotes.tsx Show resolved Hide resolved
app/utils/asciidoctor.tsx Show resolved Hide resolved

export const ui = tunnel()

const CustomDocument = ({ document }: { document: AdocTypes.Document }) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to move most of this out into shared code in @oxide/design-system – since we use the ToC on the docs site also.

node: AdocTypes.Block | AdocTypes.Inline
hasLightbox?: boolean
}) => {
const InlineImage = ({ node }: { node: Block | Inline }) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline elements we cannot use the custom renderer unfortunately. So this is formatted like a regular AsciiDoc converter function. Inline images appear in places like table cells.

<div className="content">
<pre className={cn('highlight', nowrap ? ' nowrap' : '')}>
{lang && lang === 'mermaid' ? (
<Mermaid content={decode(content)} />
<Mermaid content={node.source || ''} />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a custom Listing converter here because we want to render the Mermaid elements. I tried moving this into the shared design system library, but it was unhappy with the Mermaid import even when it was set as a peer dep.

* renderWithBreaks('/path/to/long/file.txt')
* '/<wbr/>path/<wbr/>to/<wbr/>long/<wbr/>file.txt'
*/
export const renderWithBreaks = (text: string): string => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all moved into the shared lib too now.


import Mermaid from './Mermaid'

// Custom highlight.js language definition to support TLA+
// Reference: https://github.com/highlightjs/highlight.js/pull/1658
hljs.registerLanguage('tla', function (hljs) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLA support needs be readded

baseConverter: Html5Converter

constructor() {
this.baseConverter = new InlineConverter()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now builds on top of the custom inline converter in the design system – which itself is based on the default HTML5 converter. This is for inline conversions where the AST processor doesn't reach.

@benjaminleonard benjaminleonard merged commit d79a566 into main Dec 17, 2024
4 checks passed
@benjaminleonard benjaminleonard deleted the new-prepare-document branch December 17, 2024 12:50
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

Successfully merging this pull request may close these issues.

1 participant