asciidoctor / asciidoctor-intellij-plugin

AsciiDoc plugin for products on the IntelliJ platform (IDEA, RubyMine, etc)
https://intellij-asciidoc-plugin.ahus1.de/
Apache License 2.0
342 stars 145 forks source link

support barcode extension #1327

Closed AlexCzar closed 10 months ago

AlexCzar commented 1 year ago

Why the new feature should be added

This is a part of asciidoctor-diagram, which is already supported. https://docs.asciidoctor.org/diagram-extension/latest/#barcode The extension (namely the qrcode macros) could be used for documentation which talks about mobile resources or relevant to mobile apps. It is also useful to render things like barcodes for printing labels. I imagine there are other uses as well.

How the new feature should work

When there is a barcode extension block or macro in the document, it should be rendered, same way diagrams are rendered. example:

Scan this with your phone: qrcode::https://my-link.tld/something[]

Currently document rendering/preview in IntelliJ just crashes with the following error:

unable to render AsciiDoc document

org.asciidoctor.jruby.internal.AsciidoctorCoreException: org.jruby.exceptions.LoadError: (LoadError)
You are using functionality that requires the optional gem dependency `barby` which could not be
loaded. Add `gem 'barby', '~> 0.6.8'` to your Gemfile.

At the very least, if supporting it is impossible or too hard, the rendering/preview in the IDE should not crash, which would enable at least external generation/rendering while allowing to edit comfortably in the IDE.

ahus1 commented 1 year ago

Hi @AlexCzar - thanks for raising this here. The AsciiDoc plugin uses the upstream project asciidoctorj-diagram, which bundles the Ruby gems needed of asciidoctor-diagram for consuming them with Java.

I've raised issue https://github.com/asciidoctor/asciidoctorj-diagram/issues/34 with the upstream project. Once there is an update, I can update the AsciiDoc plugin for IntelliJ.

ahus1 commented 1 year ago

The next version of this plugin will support diagrams in AsciIDoc contents thanks to the changes in the asciidoctorj-diagram dependency.

There are two known issues that I found when testing this today:

I suppose none of them should be a blocker.

Given your example above, I see that there are two colons (::) after the macro name (qrcode). Two colons are use only for block macros. When using a macro as part of a paragraph, use an inline macro with only one colon (:). Otherwise the second colon will be treated part of the code and your hyperlink will start with a colon (:https://my-link.tld/something).

So use for an inline macro:

Scan this with your phone: qrcode:https://my-link.tld/something[]

Or for a block macro:

Scan this with your phone: 

qrcode::https://my-link.tld/something[]

I'll update this issue once the next preview-version of this AsciiDoc plugin for IntelliJ is available.

ahus1 commented 1 year ago

There's now pre-release 0.38.19 which includes this change. I'd did a local test and it look ok to me. I'd be happy if you could take a look as well and comment here with your findings.

The pre-release of the plugin is available from GitHub releases and the IntelliJ AsciiDoc EAP repository.

NLH-Software commented 10 months ago

Without being the reporter, just installed the pre-release, and it works perfectly for me with my barcodes now. Before I always had to comment them to get a preview. Looking forward to find this in the released version.

ahus1 commented 10 months ago

Thank you for installing the pre-release. I published Release 0.38.20 on Jun 27, 2023 on the JetBrains marketplace, so the functionality should be available for everyone since that date once they use the plugin update functionality in IntelliJ.

Thanks for testing this change. As it works for you, I'm closing this issue.