No commit activity in last 3 years
No release in over 3 years
An extension for Asciidoctor that suppresses line breaks between east asian characters.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Asciidoctor CJK Breaks

Asciidoctor CJK Breaks is an extension for Asciidoctor that suppresses line breaks between east asian characters.

Normally newlines in a asciidoc text get rendered as newlines in output html text. Then browsers will usually render those newlines as whitespace (more smart behavior is included in w3c drafts, but not actually implemented by vendors).

This extension finds and removes newlines that cannot be converted to space, algorithm matches CSS Text Module Level 3:

  • If the character immediately before or immediately after the segment break is the zero-width space character (U+200B), then the break is removed, leaving behind the zero-width space.

  • Otherwise, if the East Asian Width property [UAX11] of both the character before and after the segment break is F, W, or H (not A), and neither side is Hangul, then the segment break is removed.

  • Otherwise, the segment break is converted to a space (U+0020).


This is a Ruby port of markdown-it-cjk-breaks.

Status: 2674483

Install

$ gem install asciidoctor_cjk_breaks

Usage

In command line:

$ asciidoctor -r asciidoctor_cjk_breaks example.adoc

In Ruby:

require 'asciidoctor_cjk_breaks'

Asciidoctor.convert_file filepath

Test

$ ruby test/test_cjk_breaks.rb

And then open the converted HTML files in test/fixtures directory.