Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect line endings #11

Open
asgrim opened this issue Oct 6, 2021 · 0 comments
Open

Detect line endings #11

asgrim opened this issue Oct 6, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@asgrim
Copy link
Member

asgrim commented Oct 6, 2021

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
@asgrim asgrim added the enhancement New feature or request label Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant