From 7d55a1ada75c5f01899f9b2f5d4cc6d730f6f8aa Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Thu, 11 Jul 2019 14:54:20 -0700 Subject: [PATCH 1/2] Fix #43 --- src/ddoc/sections.d | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ddoc/sections.d b/src/ddoc/sections.d index da737b5..a4480fe 100644 --- a/src/ddoc/sections.d +++ b/src/ddoc/sections.d @@ -106,6 +106,8 @@ Section[] splitSections(string text) // Used to strip trailing newlines / whitespace. lex.stripWhitespace(); size_t sliceStart = lex.offset - lex.front.text.length; + if (lex.front.type == Type.inlined) + sliceStart -= 2; // opening and closing '`' characters size_t sliceEnd = sliceStart; string name; app ~= Section(); @@ -280,11 +282,20 @@ unittest Throws: $(D RegexException) if there were any errors during compilation.`; - const sections = splitSections(comment); + const sections = splitSections(comment); assert(sections[2].content == "pattern(s) = Regular expression(s) to match\n" ~ " flags = The _attributes (g, i, m and x accepted)"); } +// Handle inlined code properly +unittest +{ + immutable comment = "`code` something"; + const sections = splitSections(comment); + import std.stdio; writeln(sections); + assert(sections[0].content == "`code` something"); +} + private: /** * Append a section to the given output or merge it if a section with From 817fdebaa35732faf18931dee866f6376f341862 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Thu, 11 Jul 2019 14:59:41 -0700 Subject: [PATCH 2/2] Clean up the unit test --- src/ddoc/sections.d | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ddoc/sections.d b/src/ddoc/sections.d index a4480fe..d74f7e3 100644 --- a/src/ddoc/sections.d +++ b/src/ddoc/sections.d @@ -292,7 +292,6 @@ unittest { immutable comment = "`code` something"; const sections = splitSections(comment); - import std.stdio; writeln(sections); assert(sections[0].content == "`code` something"); }