Posted by
gregturn on
Nov 27, 2013; 1:32pm
URL: https://discuss.asciidoctor.org/asciidoctorj-generates-different-HTML-than-command-line-asciidoctor-tp1137.html
My source README.adoc starts off like this:
=================================
---
categories: [rest,json,jackson,springmvc]
---
:toc:
:project_id: gs-rest-service
:spring_version: 3.2.4.RELEASE
:spring_boot_version: 0.5.0.M4
:icons: font
:source-highlighter: prettify
This guide walks you through the process of creating a "hello world" link:/understanding/REST[RESTful web service] with Spring.
...
==================================
When I run command line asciidoctor -S safe -a allow-uri-read,skip-front-matter README.adoc (because I have some include::
https://urls/to/remote.adoc[] calls), this is what I see in README.html...
==================================
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="Asciidoctor 0.1.4">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>What you’ll build</title>
<style>
...asciidoctor's styling
</style><link rel="stylesheet" href="
http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.min.css"><link rel="stylesheet" href="
http://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css"><script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script><script>document.addEventListener('DOMContentLoaded', prettyPrint)</script></head>
<body class="article">
<div id="header">
<div id="toc" class="toc">
<div id="toctitle">Table of Contents</div>
...
==================================
But when the same document is run through asciidoctorj inside my web app like this:
==================================
private final Asciidoctor asciidoctor = Asciidoctor.Factory.create();
...
Attributes attributes = new Attributes();
attributes.setAllowUriRead(true);
attributes.setSkipFrontMatter(true);
File readme = new File(unzippedRoot.getAbsolutePath() + File.separator + "README.adoc");
content = asciidoctor.renderFile(
readme,
OptionsBuilder.options().safe(SafeMode.SAFE).attributes(attributes));
==================================
...this is what I see:
==================================
<div class="paragraph">
<p>This guide walks you through the process of creating a "hello world"
RESTful web service with Spring.</p>
</div>
...
==================================
It appears the entire <html><header></header></html> part has been stripped out and only that which is inside the <div id="content"> tag. Is there a setting to give me ALL the HTML? I wanted to run a Jsoup query and extract the table of contents so I can stuff it in a sidebar. But that doesn't appear visible.