Skip to content

Detect line endings #11

@asgrim

Description

@asgrim

At the moment, the tool crashes if it encounters a file with CRLF (\r\n) line endings. The error is misleading (it says it can't find the title of the page), but we should detect these line endings being used and reject it with a more helpful error message.

Expected behaviour

  • An error message saying that CRLF (\r\n) are not supported. Suggested remediation can be to use dos2unix <filename>.

Actual behaviour

[2021-10-06T16:23:13.821568+00:00] cli.INFO: Writing HTML output to /docs-package/index.html [] []
PHP Fatal error:  Uncaught RuntimeException: First line of markdown file <filename> did not start with "# "... in /app/src/DocbookPage.php:71
Stack trace:
#0 /app/src/DocbookPage.php(83): Roave\DocbookTool\DocbookPage->determineTitleFromContent()
#1 /app/vendor/twig/twig/src/Extension/CoreExtension.php(1541): Roave\DocbookTool\DocbookPage->title()
#2 /app/vendor/twig/twig/src/Environment.php(358) : eval()'d code(226): twig_get_attribute()
#3 /app/vendor/twig/twig/src/Template.php(394): __TwigTemplate_2904b74a3842d9b80ea20a5768e5df794dec35bfd57ea5620521eb0ac55c9c23->doDisplay()
#4 /app/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()
#5 /app/vendor/twig/twig/src/Template.php(379): Twig\Template->display()
#6 /app/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\Template->render()
#7 /app/vendor/twig/twig/src/Environment.php(277): Twig\TemplateWrapper->render()
#8 /app/src/Writer/SingleStaticHtmlWriter.php(34): Twig\Environment->render()
#9 /app/src/WriteAllTheOutputs.php(22): Roave\DocbookTool\Writer\SingleStaticHtmlWriter->__invoke()
#10 /app/bin/docbook-tool.php(55): Roave\DocbookTool\WriteAllTheOutputs->__invoke()
#11 /app/bin/docbook-tool.php(59): Roave\DocbookTool\{closure}()
#12 /app/bin/docbook-tool(6): require_once('...')
#13 {main}

Next Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template ("First line of markdown file <filename> did not start with "# "..."). in /docs-src/templates/online.twig:179
Stack trace:
#0 /app/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling()
#1 /app/vendor/twig/twig/src/Template.php(379): Twig\Template->display()
#2 /app/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\Template->render()
#3 /app/vendor/twig/twig/src/Environment.php(277): Twig\TemplateWrapper->render()
#4 /app/src/Writer/SingleStaticHtmlWriter.php(34): Twig\Environment->render()
#5 /app/src/WriteAllTheOutputs.php(22): Roave\DocbookTool\Writer\SingleStaticHtmlWriter->__invoke()
#6 /app/bin/docbook-tool.php(55): Roave\DocbookTool\WriteAllTheOutputs->__invoke()
#7 /app/bin/docbook-tool.php(59): Roave\DocbookTool\{closure}()
#8 /app/bin/docbook-tool(6): require_once('...')
#9 {main}
  thrown in /docs-src/templates/online.twig on line 179
make: *** [Makefile:64: build-docs] Error 255

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions