Can Asciidoctor render a separate HTML page per chapter? - asciidoctor

If I have something like the following:
The Manual
====================
Gregg Bolinger
v1.0, 2014-15
:doctype: book
:icons: font
:imagesdir: images
Preamble paragraph
include::chapter1.ad[]
include::chapter2.ad[]
I'd like so that each chapter renders in its own HTML file and is linked to from the TOC rather than everything being in a single book.html, for example. It seems to generate separate files already, but that's only because they are in the source directory. It is still combining everything into a single HTML page. I'm using the Gradle Asciidoctor plugin, if that helps to know.

Unless there's something in the gradle plugin that does chunked html, asciidoctor does not handle chunked output at the moment. It's on the list of things to do, but it hasn't been done. If you look at the issue, however, someone has create a custom script/converter to do it though, perhaps that will work for your case as well.

Using the asciidoctor-multipage extension, each chapter can be rendered in its own HTML file. The links in the TOC points to the respective HTML chapters rather than everything being in a single book.html. At the end of every HTML page, the extension also adds links to the next or previous page, as seen on this website.
Assuming you have already installed the asciidoctor, just do $ gem install asciidoctor-multipage in your command line to install the multipage extension.
After making your file-name.adoc with various chapters, $ cd to that folder and then do $ asciidoctor -r asciidoctor-multipage -b multipage_html5 -D test/out --backend multipage_html5 -a data-uri file-name.adoc. This command will embed any images in the file-name.adoc to the new .html files which will be saved in newly created test/out folder. I only tested this using Ubuntu 20.04.

As Sam Macharia answered, asciidoctor-multipage can achieve your goal.
Also, most Docbook toolchains let you control how content is "chunked" into HTML pages, including at the book, chapter, and section levels.
Antora is the "official" way to achieve your goal.

Related

Interactive dependency map on rustdoc?

When I make projects with C++, I often use doxygen to generate the documentations, doxygen has a neat feature that generates interactive dependency graphs (like call dependencies, inheritance dependencies etc...)
This tool, embedded in the html docs, allows you to zoom in and out and drag things around.
I am trying to generate a dependency graph for the current crates of a project, this looks like this:
The image is generated using depgraph.
I have 2 issues.
Issue 1) is, as the dependency graph grows, the image becomes harder and harder to read:
This could be solved by having a zoom and pan feature like doxygen, but I have got no idea how to generate and inject that kind of html (and maybe js?) into the autodocs from rustod.
Issue 2) is that the svg file is unaffected by the css and having the white and black color scheme looks kinda ugly, this is less important but it would be nice if the svg could mirror the css theme.
Rustdoc allows for the injection of custom CSS and HTML/JS before and after the generated content. You can do this via various command-line arguments.
see: https://doc.rust-lang.org/rustdoc/command-line-arguments.html
To add custom HTML to the header you can use the --html-in-header argument.
$ rustdoc src/lib.rs --html-in-header header.html
Where header.html is your custom header HTML
This flag takes a list of files, and inserts them inside the <body>
tag but before the other content rustdoc would normally produce in the
rendered documentation.
see: https://doc.rust-lang.org/rustdoc/command-line-arguments.html#--html-before-content-include-more-html-before-the-content
$ rustdoc src/lib.rs --html-after-content extra.html
Where extra.html is your custom HTML to include after the content.
This flag takes a list of files, and inserts them before the </body>
tag but after the other content rustdoc would normally produce in the
rendered documentation.
see: https://doc.rust-lang.org/rustdoc/command-line-arguments.html#--html-after-content-include-more-html-after-the-content
Finally for custom CSS
$ rustdoc src/lib.rs --extend-css extra.css
Where extra.css is your custom css definitions.
With this flag, the contents of the files you pass are included at the
bottom of Rustdoc's theme.css file.
While this flag is stable, the contents of theme.css are not, so be
careful! Updates may break your theme extensions.
see: https://doc.rust-lang.org/rustdoc/command-line-arguments.html#-e--extend-css-extend-rustdocs-css
Unfortunately I don't have any example rust doc html - so it is hard to say exactly what should be included in your injected HTML/CSS/JS to achieve your desired results. My suggestion is that you try and if you get stuck to ask a more specific question and provide an example of the code.

How to share html report of pytest-html with out changing the css

I am using python 3.6 and pytest-html to generate HTML reports .
Everything is successfully working but when i share my html report to my manager the css of the entire document is out of placed .can someone tell the reason to why it is happening and the solution for it .
The view of reports when i run:
The view of the reports when i share the document with my manager
include --self-contained-html when you are calling your pytest...such as
pytest your.pyfilename --html=pathandfilename --self-contained-html.
Your result file have inline css in it.
html=report.html --self-contained-html
It seems like you are not sharing whole bunch of items like CSS with html file you are giving. Just place the CSS code inside your HTML rather than giving the path and it will solve your problem.

phpThumbOf or pThumb for PDF thumbnails in Modx

I'm using phpThumbOf on my site to generate resized images on my modx site. Now I tried to do a download area where I want to show some thumbnails of PDFs, but its not generating them. When I try to use pThumb, it returns the sourcefile path.
I already confirmed, that ImageMagick and php-imagick are installed and enabled.
Also my local development environment should allow to use exec so I can't see why this isn't working.
Did someone got this to work already?
Is Ghostscript running in your setup? It's needed to generate thumbnails of PDFs.
Source:
http://phpthumb.sourceforge.net/demo/docs/phpthumb.faq.txt
Quote:
Q: Can I make thumbnails from a PDF?
A: Yes, as long as you have both ImageMagick and GhostScript
installed. The AFPL version of GhostScript seems to work
better than the GNU version (at least for me it does).
http://www.imagemagick.org
http://www.cs.wisc.edu/~ghost/
You may want to use the "sfn" (Source Frame Number)
parameter of phpThumb to specify which page to thumbnail.
Use pThumb. It's the fork of phpThumbOf.
You say that you're already getting the image path (including the image?). You could put that into something like this:
<a href="[[+image:pthumb=`w=800&h=400&zc=0`]]" rel="lightbox" title="Click for enlagement" >
<img src="[[+image:pthumb=`w=150&h=150&zc=0`]]" />
</a>
Or whatever options you might want. It is always good practice to output the image TV's as text, so you have full control over the actual code.

Include an SVG (hosted on GitHub) in MarkDown

I know that an image can be placed in an MD with the MD syntax of either ![Alt text](/path/to/img.jpg) or ![Alt text](/path/to/img.jpg "Optional title"), but I am having difficulty placing an SVG in MD where the code is hosted on GitHub.
Ultimately using rails3, and changing the model frequently right now, so I am using RailRoady to generate an SVG of the schema diagram of the models. I would like for that SVG to then be placed in the ReadMe.md, and be displayed. When I open the SVG file locally, it does work, so how do I get the browser to render the SVG in the MD file? Given that the code will be dynamic until it is finalized (seemingly never), hosting the SVG in a separate place seems overkill and that I am missing an approach to accomplish this.
The SVG I am trying to include is here on GitHub: https://github.com/specialorange/FDXCM/blob/master/Rails/fdxcm/doc/models_brief.svg
I have tried the following, with an actual image as well to verify the syntax is working, just that the SVG code isn't being rendered:
![Overview][1]
[1]: https://github.com/specialorange/FDXCM/blob/master/doc/controllers_brief.svg "Overview"
<img src="https://raw.github.com/specialorange/FDXCM/master/doc/controllers_brief.svg">
![Alt text](https://raw.github.com/specialorange/FDXCM/master/doc/controllers_brief.svg)
[Google Doc](https://docs.google.com/drawings/d/1B95ajItJTAImL2WXISX0fkBLYk3nldea4Vm9eo-VyE4/edit) :
<img src="https://docs.google.com/drawings/pub?id=117XsJ1kDyaY-n8AdPS3_8jTgMyITqaoT3-ah_BSc9YQ&w=960&h=720">
<img src="https://raw.github.com/specialorange/FDXCM/master/doc/controllers_brief.svg">
<img src="https://docs.google.com/drawings/d/1B95ajItJTAImL2WXISX0fkBLYk3nldea4Vm9eo-VyE4/edit">
to get the results of:
1: https://github.com/specialorange/FDXCM/blob/master/Rails/fdxcm/doc/controllers_brief.svg "Overview"
Google Doc :
The purpose of raw.github.com is to allow users to view the contents of a file, so for text based files this means (for certain content types) you can get the wrong headers and things break in the browser.
When this question was asked (in 2012) SVGs didn't work. Since then Github has implemented various improvements. Now (at least for SVG), the correct Content-Type headers are sent.
Examples
All of the ways stated below will work.
I copied the SVG image from the question to a repo on github in order to create the examples below
Linking to files using relative paths (Works, but obviously only on github.com / github.io)
Code
![Alt text](./controllers_brief.svg)
<img src="./controllers_brief.svg">
Result
See the working example on github.com.
Linking to RAW files
Code
![Alt text](https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg)
<img src="https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg">
Result
Linking to RAW files using ?sanitize=true
Code
![Alt text](https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg?sanitize=true)
<img src="https://raw.github.com/potherca-blog/StackOverflow/master/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg?sanitize=true">
Result
Linking to files hosted on github.io
Code
![Alt text](https://potherca-blog.github.io/StackOverflow/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg)
<img src="https://potherca-blog.github.io/StackOverflow/question.13808020.include-an-svg-hosted-on-github-in-markdown/controllers_brief.svg">
Result
Some comments regarding changes that happened along the way:
Github has implemented a feature which makes it possible for SVG's to be used with the Markdown image syntax. The SVG image will be sanitized and displayed with the correct HTTP header. Certain tags (like <script>) are removed.
To view the sanitized SVG or to achieve this effect from other places (i.e. from markdown files not hosted in repos on http://github.com/) simply append ?sanitize=true to the SVG's raw URL.
As stated by AdamKatz in the comments, using a source other than github.io can introduce potentially privacy and security risks. See the answer by CiroSantilli and the answer by DavidChambers for more details.
The issue to resolve this was opened on Github on October 13th 2015 and was resolved on August 31th 2017
I contacted GitHub to say that github.io-hosted SVGs are no longer displayed in GitHub READMEs. I received this reply:
We have had to disable svg image rendering on GitHub.com due to potential cross site scripting vulnerabilities.
Update 2020: how they made it work while avoiding XSS attacks
GitHub appears to use two security approaches, this is a good article: https://digi.ninja/blog/svg_xss.php see also: https://security.stackexchange.com/questions/148507/how-to-prevent-xss-in-svg-file-upload
show SVG inside <img tag, which prevents scripts from running, e.g. on READMEs: https://github.com/cirosantilli/test-git-web-interface/tree/8e394cdb012cba4bcf55ebdb89f36872b4c6c12a
use Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox. This prevents the script from running even in raw which contains the raw SVG file: https://raw.githubusercontent.com/cirosantilli/test-git-web-interface/8e394cdb012cba4bcf55ebdb89f36872b4c6c12a/svg-foreignObject.svg
You can see the header with curl -vvv. The regular github.com pages also have a content-security-policy, but it is much larger.
Update 2017
A GitHub dev is currently looking into this: https://github.com/github/markup/issues/556#issuecomment-306103203
Update 2014-12: GitHub now renders SVG on blob show, so I don't see any reason why not to render on README renderings:
https://github.com/blog/1902-svg-viewing-diffing
https://github.com/cirosantilli/test/blob/2144a93333be144152e8b0d4144b77b211afce63/svg.svg
Also note that that SVG does have an XSS attempt but it does not run: https://raw.githubusercontent.com/cirosantilli/test/2144a93333be144152e8b0d4144b77b211afce63/svg.svg
The billion laugh SVG does make Firefox 44 Freeze, but Chromium 48 is OK: https://github.com/cirosantilli/web-cheat/blob/master/svg-billion-laughs.svg
Petah mentioned that blobs are fine because the SVG is inside an iframe.
Possible rationale for GitHub not serving SVG images
general XML vulnerabilities. E.g. opening a billion laughs exploit just made Firefox crash my system. Firefox bug with exploit attached: https://bugzilla.mozilla.org/page.cgi?id=voting/user.html. Same on Chromium: https://code.google.com/p/chromium/issues/detail?id=231562
SVG XSS scripting: while most browsers don't run scripts when the SVG is embedded with img, it seems that this is not required by the standards, so maybe GitHub is playing it safe.
Browsers do run it if you open the SVG directly (but it appears that GitHub never shows images directly on the github.com domain) or if it is inline (which are currently completely removed by GitHub), so those cases shouldn't be a security concern. Relevant links:
spec: http://www.w3.org/TR/SVG/script.html
interactive SVG demo: http://www.w3.org/TR/SVG/images/script/script01.svg
The following questions asks about the risks of SVG in general: https://security.stackexchange.com/questions/11384/exploits-or-other-security-risks-with-svg-upload
rawgit.com solves this problem nicely. For each request, it retrieves the appropriate document from GitHub and, crucially, serves it with the correct Content-Type header.
Since Jan. 2022, that seems possible (and easy):
Allow to upload .svg files to Markdown
It is now possible to upload .svg files to comments in issues, PRs, discussions, and Markdown files, like READMEs.
You just have to drag and drop the file in the text area.
This will work. Link to your SVG using the following pattern:
https://cdn.rawgit.com/<repo-owner>/<repo>/<branch>/path/to.svg
The downside is hardcoding the owner and repo in the path, meaning the svg will break if either of those are renamed.
I have a working example with an img-tag, but your images won't display.
The difference I see is the content-type.
I checked the github image from your post (the google doc images don't load at all because of connection failures). The image from github is delivered as content-type: text/plain, which won't get rendered as an image by your browser.
The correct content-type value for svg is image/svg+xml. So you have to make sure that svg files set the correct mime type, but that's a server issue.
Try it with http://svg.tutorial.aptico.de/grafik_svg/dummy3.svg and don't forget to specify width and height in the tag.
Just like this worked for me on Github.
![Image Caption](ImageAddressOnGitHub.svg)
or
<img src="ImageAddressOnGitHub.svg">
In addition to regular SVGs, you can also insert animated SVG images in the markdown file like any other format. It can be a good alternative to GIF images.
Use relative links if both your animated SVG and your markdown file are in the same GitHub repository:
![image description](relative/path/in/repository/to/image.svg)
OR
<img src="relative/path/in/repository/to/image.svg" width="128"/>
Example (assuming the image is in assets directory in the repository):
![My animated logo](assets/my-logo.svg)
Result:
Use this site: https://rawgit.com , it works for me as I don't have permission issue with the svg file.
Please pay attention that RawGit is not a service of github, as mentioned in Rawgit FAQ :
RawGit is not associated with GitHub in any way. Please don't contact GitHub asking for help with RawGit
Enter the url of svg you need, such as :
https://github.com/sel-fish/redis-experiments/blob/master/dat/memDistrib-jemalloc-4.0.3.svg
Then, you can get the url bellow which can be used to display:
https://cdn.rawgit.com/sel-fish/redis-experiments/master/dat/memDistrib-jemalloc-4.0.3.svg

How to modify Sharepoint filetype icons depending on parts of the filename?

We have a SharePoint Document library, where we store html files with links to external files. Samples:
mypicture.jpg.html
mywordfile.docx.html
mypdffile.pdf.html
and so on. Now by default all Files show up with the HTML Icon, referenced in the DOCICON.XML file. Thats of course correct as the .html extension shows, it is a HTML file. But we want the files to have different icons, based on their original file type.
Is there a way to automatically change the Icon
during rendering or
when we save the file to the library (via SharePoint API)?
Any other approachs?
Why not use a little jquery to change the icon during rendering? Each doc in your library should be contained in
<td class="ms-vb-icon"><a tabindex=...><img ... src="/_layouts/images/ichtm.gif"></a></td>
I think you can slurp that into an array, assign a new var that's just the href stripped of path/filename. and .html, and use that to replace htm in the src tag.
Could you not just edit the DOCICON.xml to add the ".jpg.html" and ".docx.html" extensions in?
For a full listing of icon files see all "ic*.gif" files in the TEMPLATE\IMAGES directory under the 12 hive. Unfortunately, this will not solve your problem, but this is where you can change it based on the extension, if you so choose.
Note that a blog I wrote a while back has a different focus, but does discuss where the icons come from: http://wiki.threewill.com/display/is/2007/10/14/External+Link+for+Editing+a+SharePoint+Document.

Resources