Skip to content

Render AsciiDoc package READMEs on the Info tab - #616

Open
AMDphreak wants to merge 1 commit into
dlang:masterfrom
AMDphreak:feature/asciidoc-readme
Open

Render AsciiDoc package READMEs on the Info tab#616
AMDphreak wants to merge 1 commit into
dlang:masterfrom
AMDphreak:feature/asciidoc-readme

Conversation

@AMDphreak

Copy link
Copy Markdown

Summary

  • Prefer README.md, then README.adoc / README.asciidoc, then bare README, then other README* files.
  • Store readmeFormat / readmeFile and render AsciiDoc via asciidoctor-d (secure HTML fragment).
  • Sanitize README HTML (strip script/style/handlers) and add light AsciiDoc CSS.
  • Preserve historical default of Markdown filtering for older DB documents without readmeFormat.

Depends on fragment/secure support in asciidoctor-d (feature/html5-fragment-safe). Until that lands on a tagged release, dub.sdl points at that branch.

Test plan

  • Package with only README.adoc shows formatted Info tab (headings, lists, code)
  • Package with README.md unchanged
  • AsciiDoc passthrough / javascript: links are neutralized
  • Relative image/link rewriting still works for GitHub packages

Made with Cursor

Detect README.adoc/.asciidoc, convert with asciidoctor-d in secure
fragment mode, and keep Markdown behavior for README.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread dub.sdl
dependency "dub" version="~>1.33"
dependency "userman" version="~>0.4.0"
dependency "uritemplate" version="~>1.0.0"
dependency "asciidoctor-d" version="~feature/html5-fragment-safe" repository="git+https://github.com/dlang-supplemental/asciidoctor-d.git"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This dependency should probably get registered at code.dlang.org.
More importantly, DUB’s selections file has not been updated to reflect this change.

Comment on lines +212 to +213
static dangerous = ctRegex!(
`(?is)<\s*(script|style|iframe|object|embed|link|meta|form|input|button|textarea|select)(\s[^>]*)?>.*?<\s*/\s*\1\s*>|<\s*(script|style|iframe|object|embed|link|meta|form|input|button|textarea|select)(\s[^>]*)?/?>`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I’m not keen on such a block-list approach.

Also, wasn’t it general wisdom to never use regex for parsing XML or HTML? Has this changed?

@@ -0,0 +1,83 @@
/* Lightweight AsciiDoc fragment styles for the package Info tab */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do they need their own distinct styling? Should they rather be styled in tandem with markdown documents?

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.

2 participants