by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 02 19:55
    yalmuhaidib opened #3674
  • Jun 01 09:09
    cirosantilli edited #3147
  • Jun 01 09:07
    cirosantilli edited #3148
  • Jun 01 09:07
    cirosantilli edited #3345
  • Jun 01 09:06
    cirosantilli edited #3354
  • Jun 01 09:05
    cirosantilli edited #3355
  • Jun 01 09:03
    cirosantilli edited #3358
  • May 28 09:49
    mojavelinux closed #3653
  • May 25 20:35
    mojavelinux assigned #3662
  • May 25 20:35
    mojavelinux closed #3662
  • May 24 23:54
    mojavelinux labeled #3673
  • May 24 20:08
    mojavelinux closed #3651
  • May 24 17:21
    lucki1000 closed #3673
  • May 24 14:08
    lucki1000 opened #3673
  • May 24 10:20
    opoudjis opened #3672
  • May 23 04:16
    djencks opened #3671
  • May 23 04:09
    djencks opened #3670
  • May 22 22:32
    Mogztter opened #3669
  • May 22 22:29
    Mogztter opened #3668
  • May 22 22:25
    Mogztter opened #3667
Dan Allen
@mojavelinux
I am VERY close to getting the new keep together logic working in Asciidoctor PDF. then I'm going to switch to adding the block border and shading after the content (instead of before). and finally, we will make keep together opt in.
the new logic tracks the start and end cursor instead of the block height, which means it draws the border and background around the content accurately
and it means we don't have to move a block to the next page if it has to be split anyway
David Jencks
@djencks_gitlab
Hmm, It seems to me that all the looping behavior in paged.js comes from their page break algorithm trying to keep things together. I have a hard time understanding their logic. Where is your algorithm for this?
Dan Allen
@mojavelinux
the algorithm in Asciidoctor PDF is very primitive. it was just woefully broken, which I'm fixing
the algorithm is to try to use a full page. if it fits on the previous page, move it back. if it doesn't fit on a full page, move it back and let it break normally.
but there is no orphan or widow support. this is just about drawing the boxes accurately.
David Jencks
@djencks_gitlab
I found an academic paper on pagination for TeX which seemed to indicate that it's not a very well understood problem.
Dan Allen
@mojavelinux
the problem in Asciidoctor PDF is that it cannot move things around once they are rendered. so you have to keep rendering over and over until you get it where you want it. which is never going to be great, but it can at least not make mistakes
it's an extremely difficult problem to solve, but the browser w/ JavaScript at least gives us the best tools to work on it.
David Jencks
@djencks_gitlab
Maybe you know offhand the answer to this.... paged.js overflow detection off the bottom of the page looks for a block that is too wide, I would naively have expected the height to be too large rather than the width. Do you know why? IIUC it's looking at the boxes chromium comes up with.
Dan Allen
@mojavelinux
i don't have that level of familiarity with paged.js (yet). though what you're expecting seems logical to me.
matrixbot
@matrixbot
@pablo Hey peeps. Is there a guide on how tto procedurally create an asciidoc document using the Asciidoctor ruby API?
@pablo I need to proceduraly append some data to an existing document
Guillaume Grossetie
@Mogztter
You should check out the Asciidoctor Ruby API documentation: https://www.rubydoc.info/github/asciidoctor/asciidoctor/Asciidoctor%2FAbstractBlock:%3C%3C
You can also find some examples on how to create a blocks/nodes from the Asciidoctor extensions lab repository on GitHub
As far as I know there's no official guide but you can find some resources here and there
matrixbot
@matrixbot

@pablo > <@gitter_mogztter:matrix.org> You should check out the Asciidoctor Ruby API documentation: https://www.rubydoc.info/github/asciidoctor/asciidoctor/Asciidoctor%2FAbstractBlock:%3C%3C

Thanks! I was looking for this kind of documentation but I couldn't find it. Really helped me outhere (I was reading the inline docs in the source code before I read your message hehe)

@pablo Also, there were a fell things I coundn't figure out after reading the docs:
  1. How to configure the documents favicon via the Asciidoctor API

@pablo * Also, there were a fell things I coundn't figure out after reading the docs:

  1. How to configure the documents favicon via the Asciidoctor API?

  2. How to remove the numbers that preceed the section titles?

  3. How to make a link bold? My intuition was to create an Inline with context set to :inline_anchor and :type set to :xref and place it inside an empty paragraph Block with :type set to :strong, but that doesn't seem to work.

skanehira
@skanehira
Hi
I'm developping the asciidoc editor with asciidoctor.js
Can I ask some questions in this room?
David Jencks
@djencks_gitlab
Sure!
skanehira
@skanehira
Thank you :)
skanehira
@skanehira

I developing WYSIWYG editor with editor.js and asciidoctor.js
https://editorjs.io

editor.js is block style.
I have no idea how create block from file because file is not structed text.
This is my current problem.

asciidoctor.js Document object has blocks property, so I thought it could be converted to HTML in block units and tried it.

But the section titles, admonitions doesn't converted to HTML.(There may be other syntax that is not converted)

e.g
file contents.

== This is section
- Gorilla
- Cat

[NOTE]
====
- Dog
- Bird
- Cat
====

converted HTML.

<div class="ulist">
<ul>
<li>
<p>Gorilla</p>
</li>
<li>
<p>Cat</p>
</li>
</ul>
</div><div class="ulist">
<ul>
<li>
<p>Dog</p>
</li>
<li>
<p>Bird</p>
</li>
<li>
<p>Cat</p>
</li>
</ul>
</div>

The sample convert code.

const asciidoctor = new Asciidoctor()

function convert(blocks) {
  let output = ""
  for (const block of blocks) {
    if (block.hasBlocks() && block.blocks[0].node_name !== "list_item") {
      output += convert(block.blocks)
    } else {
      output += block.convert()
    }
  }
  return output
}

function output() {
  const input = document.getElementById("input")
  const output = document.getElementById("output")
  const doc = asciidoctor.load(input.value)
  output.innerHTML = convert(doc.blocks)
}

Is there a way to convert syntax such as selections and admonitions?

image.png
↑ The screenshot
Dan Allen
@mojavelinux
you shouldn't be calling the convert method on the inner objects. otherwise, you are just going to get the inner HTML. the converter assumes that it is recursing itself. so you can find a specific node in the tree and call convert on it, then you will get all the HTML downwards from that point.
as you can see, the content method iterates over the blocks, which calls convert on each block, which in turn calls content on each block
so if you try to convert each individual block, you are just going to get the inner HTML, which is why all you are getting are the lists.
skanehira
@skanehira
Oh, I see...
skanehira
@skanehira

I imaged block like following.

e.g
This is one block

== This is section
- Gorilla
- Cat

This is one block

[NOTE]
====
- Dog
- Bird
- Cat
====

Is there any other way to get the block html?

Guillaume Grossetie
@Mogztter
It's more like a Tree
For instance, the admonition could contain multiple inner blocks
So you need to visit the tree to get the block HTML
Guillaume Grossetie
@Mogztter
But as far as I understand Editor.js has a flat structure?
Dan Allen
@mojavelinux
as @Mogztter points out, the section block is not independent from the admonition block. rather, the section block contains the admonition block. unlike Markdown, for instance, AsciiDoc actually has a tree structure
Pavel Anni
@pavelanni
Hi, I came to this page by googling the Prawn::Errors::CannotFit error I got from asciidoctor-pdf... and I couldn't stop reading :-) I have a question for you guys: I have just joined a new company and I'm trying to convince them that Asciidoc is the right way to keep all our documentation and knowledge base and it can produce beautiful HTML and PDF from a single source. But after reading this forum (especially remarks from @mojavelinux from mid-2019) I started worrying about the state of the asciidoctor-pdf project... So tell me please: should we use it now or there is a more stable (maybe longer) way (via DocBook, LaTex, etc.)? Sorry for such a naive question... Thanks!
David Jencks
@djencks_gitlab
Dan has been spending a lot of time on Asciidoctor-pdf lately, so I doubt it's in any danger of disappearing :-). That said, it's very tempting to work on pdfs using the css paged media spec, mostly supported by the paged.js library. However, that's not very stable yet, despite our best wishes and hopes.
If you are just starting to consider asciidoc, you might also want to look into Antora: I think the large-scale organization it brings is at least as useful as the small scale organization of asciidoc.
Dan Allen
@mojavelinux

But after reading this forum (especially remarks from @mojavelinux from mid-2019)

I'm as transparent as possible, so some of what I say may seem surprising. but then you can be confident there are no hidden dragons. we lay it all out on the table here.

yes, generating PDF is always going to be a huge pain because PDF is a pain (and really mean to us). but we do everything we can do to get the best result. there will be many paths to PDF because the format forces you to prioritize its tradeoffs.
there are at least 3 paths at the moment. Asciidoctor PDF, the DocBook toolchain (fop or dblatex), and the emerging asciidoctor-pdf.js. The future is very much the latter since only the browser has the power to give us all the layout capabilities we want. as the saying goes, never bet against the web.
but for 80-90% of use cases, Asciidoctor PDF is going to be absolutely fine. If you are hitting limits, chances are you are asking too much of the PDF output. you need to question whether it's really that important what you're trying to do.
PDF is extremely limited and also dying. so while I know government this and corporate that are going to say "we need PDF" the reality is, the web is overtaking those needs very quickly and most of the time the document just gets downloaded to rot
PDF is rather crucial for print media, but books have far less requirements than screen, and we've been able to meet most of those requirements with Asciidoctor PDF.
Dan Allen
@mojavelinux
(several publishers are using the output of Asciidoctor PDF to send to the printer)
all that to say, try Asciidoctor PDF. chances are, it will work out for you. you may need to tweak a few things in your content, but it's the quickest way to get a professional PDF output. but also watch this space for news about asciidoctor-pdf.js, which first aims to match Asciidoctor PDF, then will surpass it. but that's likely a few quarters away.
I recommend avoiding the DocBook toolchain because it is extremely painful to use and customize. it's really there for people who already know how (and they do appreciate being able to use it, trust me)
Pavel Anni
@pavelanni
Brilliant! This is exactly the information that I asked for! Many thanks, @djencks_gitlab and @mojavelinux !