fix: mount StringsScope, keep list inline text, show FOB until scroll down
This commit is contained in:
parent
9a11194f77
commit
65e693b9c6
6 changed files with 281 additions and 27 deletions
|
|
@ -156,9 +156,21 @@ void _appendBlocks(XmlElement element, String pageUrl, List<MewsBlock> out) {
|
|||
out.addAll(embedded);
|
||||
case 'blockquote':
|
||||
final children = <MewsBlock>[];
|
||||
for (final child in element.children.whereType<XmlElement>()) {
|
||||
_appendBlocks(child, pageUrl, children);
|
||||
final embedded = <MewsBlock>[];
|
||||
// Bare inline content (quotes are often written as plain text) becomes
|
||||
// a paragraph, like in list items.
|
||||
final inline = <MewsInline>[];
|
||||
for (final node in element.children) {
|
||||
final isInlineNode = node is XmlText ||
|
||||
(node is XmlElement && _inlineElements.contains(node.name.qualified));
|
||||
if (isInlineNode) {
|
||||
_appendInline(node, pageUrl, inline, embedded);
|
||||
} else if (node is XmlElement) {
|
||||
_appendBlocks(node, pageUrl, children);
|
||||
}
|
||||
}
|
||||
if (inline.isNotEmpty) children.insert(0, ParagraphBlock(inline));
|
||||
children.addAll(embedded);
|
||||
out.add(QuoteBlock(children));
|
||||
case 'pre':
|
||||
out.add(PreBlock(element.innerText));
|
||||
|
|
@ -193,13 +205,33 @@ void _appendBlocks(XmlElement element, String pageUrl, List<MewsBlock> out) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Inline-only elements; text and images directly inside these become part of
|
||||
/// the enclosing paragraph's inline run.
|
||||
const _inlineElements = {
|
||||
'a', 'br', 'em', 'strong', 'b', 'i', 'code', 'kbd', 'samp', 'var', 'q',
|
||||
'cite', 'abbr', 'dfn', 'img',
|
||||
};
|
||||
|
||||
ListBlock _listBlock(XmlElement element, String pageUrl) {
|
||||
final items = <MewsListItem>[];
|
||||
for (final li in element.findElements('li')) {
|
||||
final blocks = <MewsBlock>[];
|
||||
for (final child in li.children.whereType<XmlElement>()) {
|
||||
_appendBlocks(child, pageUrl, blocks);
|
||||
final embedded = <MewsBlock>[];
|
||||
// List items commonly hold bare inline content (the dated-link entry
|
||||
// pattern in spec 6.1), so direct text and inline elements form a
|
||||
// paragraph while block-level children append as blocks.
|
||||
final inline = <MewsInline>[];
|
||||
for (final node in li.children) {
|
||||
final isInlineNode = node is XmlText ||
|
||||
(node is XmlElement && _inlineElements.contains(node.name.qualified));
|
||||
if (isInlineNode) {
|
||||
_appendInline(node, pageUrl, inline, embedded);
|
||||
} else if (node is XmlElement) {
|
||||
_appendBlocks(node, pageUrl, blocks);
|
||||
}
|
||||
}
|
||||
if (inline.isNotEmpty) blocks.insert(0, ParagraphBlock(inline));
|
||||
blocks.addAll(embedded);
|
||||
items.add(MewsListItem(blocks));
|
||||
}
|
||||
return ListBlock(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue