This behavior is currently produced by design, but it is very hard to debug. I think we should reconsider and make the string parser silently omit the element when the underlying parser produces an optional attribute.
Consider a markdown-like paragraph:
constexpr auto section_text_def = as<std::string>(
+(
lexeme[!lit('#') >> +(char_ - eol)] >>
// always output the first eol as LF
((eol | eoi) >> attr('\n')) >>
// squash subsequent eols to single LF
// -(+eol >> attr('\n')) // <--- this outputs '\0'
(+eol >> attr('\n') | eps) // <--- workaround
)
);
This behavior is currently produced by design, but it is very hard to debug. I think we should reconsider and make the string parser silently omit the element when the underlying parser produces an optional attribute.
Consider a markdown-like paragraph: