Skip to content

Remove video format hack#4

Merged
srid merged 3 commits intosrid:masterfrom
kukimik:patch-1
Jul 18, 2023
Merged

Remove video format hack#4
srid merged 3 commits intosrid:masterfrom
kukimik:patch-1

Conversation

@kukimik
Copy link
Copy Markdown
Contributor

@kukimik kukimik commented Feb 2, 2023

Video embedding is now supported in emanote. I suppose this is no longer needed. Or is it used by some other project or should be kept for backwards compatibility reasons?

@srid srid merged commit e7150aa into srid:master Jul 18, 2023
srid added a commit that referenced this pull request Apr 29, 2026
The "tag" attribute on a B.Div is a directive used by groupRawHtmlBlocks
(in RawHtmlGroup) to override the rendered element name. The directive's
key was scattered as a string literal across three sites — the producer
in RawHtmlGroup and two consumers (getTag, dropTagAttr) buried in a
where-clause inside rpBlock'.

Promote the protocol to first-class names in Render.Internal:

- tagDirectiveKey :: Text — the single source of truth for the key.
- divTag :: Text -> B.Attr -> Text — formerly the local getTag.
- stripTagDirective :: B.Attr -> B.Attr — formerly the local dropTagAttr.

RawHtmlGroup now imports tagDirectiveKey when constructing the Div, and
the Div arm of rpBlock' calls divTag/stripTagDirective directly. The
where-clause in rpBlock' loses two helpers and Map import; everything
else is unchanged.

Addresses Hickey #2 (named protocol over implicit convention) and
Lowy #2/#4 (extract tagDirectiveKey + named helper for dropTagAttr).
srid added a commit that referenced this pull request Apr 29, 2026
…ent (#16)

* fix(rawhtml): group orphan opener/closer raw-HTML blocks

CommonMark "type 6" HTML blocks end at the next blank line, so markdown
like

    <details>

    **bold** content

    </details>

reaches the renderer as three blocks: an opener `RawBlock` carrying
`"<details>\n"`, a `Para`, and a closer `RawBlock` with `"</details>\n"`.
The current rawNode wraps each raw blob in its own `<rawhtml>` element
to keep xmlhtml from mangling the bytes; the side effect is that the
`<details>` open and close tags get trapped inside their wrappers and
the markdown paragraph ends up a sibling of the (empty) details element
rather than its child.

New `Heist.Extra.Splices.Pandoc.RawHtmlGroup.groupRawHtmlBlocks` pass
walks the AST (via `Text.Pandoc.Walk`, so nested block lists are covered
too) and rewrites those orphan triplets into a `B.Div` carrying the tag
in its `"tag"` attribute. The `Div` arm of `rpBlock'` already turns that
into the named element. It now also strips the `"tag"` directive before
serialising attributes so the override doesn't leak as a literal
`tag="…"` attribute on the rendered element.

Tests: 12 unit tests pin the parser and grouping behaviour (issue
example, empty group, orphan open/close, consecutive pairs, same-tag
nesting via depth counting, self-closing rejection, balanced-in-one-block
rejection, case-insensitive matching, attribute tolerance, hyphenated
custom-element names, mismatched-tag orphan), plus an end-to-end
integration test through `renderPandocWith` that asserts the markdown
paragraph lands inside `<details>` with no `<rawhtml>` wrapper.

Closes srid/emanote#433.

* fix(police): hlint — use isAsciiLower/isAsciiUpper/isDigit, eta-reduce raw helper

* refactor(hickey): closerTag — require explicit '>' so a malformed </tag (no '>') doesn't silently match

* refactor(hickey+lowy): hoist tag-directive helpers into Render.Internal

The "tag" attribute on a B.Div is a directive used by groupRawHtmlBlocks
(in RawHtmlGroup) to override the rendered element name. The directive's
key was scattered as a string literal across three sites — the producer
in RawHtmlGroup and two consumers (getTag, dropTagAttr) buried in a
where-clause inside rpBlock'.

Promote the protocol to first-class names in Render.Internal:

- tagDirectiveKey :: Text — the single source of truth for the key.
- divTag :: Text -> B.Attr -> Text — formerly the local getTag.
- stripTagDirective :: B.Attr -> B.Attr — formerly the local dropTagAttr.

RawHtmlGroup now imports tagDirectiveKey when constructing the Div, and
the Div arm of rpBlock' calls divTag/stripTagDirective directly. The
where-clause in rpBlock' loses two helpers and Map import; everything
else is unchanged.

Addresses Hickey #2 (named protocol over implicit convention) and
Lowy #2/#4 (extract tagDirectiveKey + named helper for dropTagAttr).

* docs(lowy): RawHtmlGroup header — volatility axis + internal-API status

* refactor(police): elegance — extract shared parseTagAfterPrefix helper

openerTag and closerTag both stripped a prefix, parsed a tag-name span,
and verified that nothing but whitespace followed the closing '>'. The
opener has one extra check (reject self-closing); other than that the
two parsers were the same shape. Extract the shared work into one
parseTagAfterPrefix and let openerTag layer the void-element rejection
on top.

* refactor(police): rehome tag-directive helpers in RawHtmlGroup, drop unused defaultTag

The tag-directive scheme (key + resolver + stripper) was sitting in
Render.Internal — a module whose docstring scopes it to "pure helpers
extracted from Render.hs", i.e. table rendering. The producer of the
directive is RawHtmlGroup, and the volatility lives there: any future
change to the wire format starts at the module that decides what shape
to emit. Move the three helpers to RawHtmlGroup (the producer) and have
Render import from there. Render.Internal is back to its original
table-helpers scope.

While moving, also drop the unused defaultTag parameter on divTag —
every call site passes "div"; bake it in. Switch divTag from
Map.fromList+Map.lookup to plain Data.List.lookup since attr lists are
flat assoc lists with no duplicates in practice (no behaviour change for
real input). Save a Map allocation per Div on the rendering hot path.

* docs(police): clean up stale getTag refs and trim oversized docstrings

- RenderSpec: comment said 'getTag' but the helper was renamed to divTag.
- RawHtmlGroup module docstring: trim the Public-surface paragraph from
  three sentences to one — the rest narrated cabal config that is one
  grep away.
- RawHtmlGroupSpec: drop the 'Block helpers' header comment that
  narrated what the next three lines obviously are.
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