Repository navigation
Add Markdown parsing with inline styles for summary text - #18
Conversation
markedライブラリを導入し、LLMからの要約テキストをMarkdown→HTML変換して表示する。 Content Scriptのインラインスタイル制約に対応するため、カスタムレンダラーで 全HTML要素にインラインスタイルを付与する。 - 見出し、リスト、テーブル、太字、コードブロック等のMarkdown書式に対応 - GFM (GitHub Flavored Markdown) と改行変換を有効化 - summaryTextのwhite-space: pre-wrapを削除(Markdown側で改行を処理) https://claude.ai/code/session_01HZXjGzM62CydxVMYw1bbZn
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e76f7ee85
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const langAttr = token.lang ? ` data-lang="${token.lang}"` : ''; | ||
| return `<pre style="${MARKDOWN_STYLES.pre}"${langAttr}><code style="${MARKDOWN_STYLES['pre code']}">${token.text}</code></pre>`; |
There was a problem hiding this comment.
Escape code-fence fields before rendering
<pre> blocks
code() interpolates both token.lang and token.text directly into HTML without escaping, and this HTML is later inserted via innerHTML; a crafted fenced block (for example, a language string containing " ><img ...>) can break out of attributes and inject executable markup, and even normal snippets containing <tag> will be interpreted as DOM instead of literal code. Please HTML-escape both values (or delegate to marked’s safe code rendering path) before concatenation.
Useful? React with 👍 / 👎.
| }, | ||
| link(token: Tokens.Link) { | ||
| const text = this.parser.parseInline(token.tokens); | ||
| return `<a href="${token.href}" target="_blank" rel="noopener noreferrer" style="${MARKDOWN_STYLES.a}">${text}</a>`; |
There was a problem hiding this comment.
Block unsafe URL schemes when rendering markdown links
link() writes token.href straight into href, so markdown like [open](javascript:alert(1)) becomes an executable link in the rendered summary; this is a new behavior from the markdown conversion path and allows untrusted summary content to trigger script execution on click. Validate schemes (e.g., allow only http:/https:) and escape the attribute value before rendering.
Useful? React with 👍 / 👎.
- code/codespanレンダラーでtoken.langとtoken.textをHTMLエスケープ - linkレンダラーでURLスキームをhttp/httpsのみに制限 - linkレンダラーでhref属性値をHTMLエスケープ https://claude.ai/code/session_01HZXjGzM62CydxVMYw1bbZn
|
@codex |
Summary
Testing
|
Summary
This PR adds Markdown parsing support to summary text rendering in the content script. Since content scripts cannot use global CSS, the implementation applies inline styles directly to HTML elements generated from Markdown.
Key Changes
markdownParser.tsutility: Created a custom Markdown parser using themarkedlibrary with a styled renderer that applies inline CSS to all HTML elements (headings, paragraphs, lists, code blocks, tables, links, etc.)summaryHtmlBuilder.ts: Integrated Markdown parsing into the summary text rendering pipeline by callingparseMarkdown()on the summary text before inserting it into the DOMstyles.ts: Removedwhite-space: pre-wrap;fromsummaryTextstyle since Markdown rendering now handles whitespace and formatting properlymarkeddependency: Addedmarked@^17.0.4to package.json for Markdown parsingImplementation Details
markdownParser.tsdefines inline styles for all Markdown elements (h1-h6, p, ul, ol, li, strong, em, blockquote, code, pre, table, hr, links, etc.)markedconfigurationtarget="_blank"andrel="noopener noreferrer"for securitydata-langattributehttps://claude.ai/code/session_01HZXjGzM62CydxVMYw1bbZn