Bug 251329 - textproc/asciidoc: extraneous carriage returns in output
Summary: textproc/asciidoc: extraneous carriage returns in output
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Sunpoet Po-Chuan Hsieh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-23 14:51 UTC by Diane Bruce
Modified: 2020-12-20 20:00 UTC (History)
2 users (show)

See Also:
fernape: maintainer-feedback? (sunpoet)


Attachments
patch to go into files dir of asciidoc (422 bytes, text/plain)
2020-11-23 14:51 UTC, Diane Bruce
no flags Details
Alternative patch to the lineend problem with comms/fldigi (448 bytes, patch)
2020-11-24 09:27 UTC, Rainer Hurling
no flags Details | Diff
patch with newest (73.85 KB, patch)
2020-12-11 17:57 UTC, Rainer Hurling
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Diane Bruce freebsd_committer 2020-11-23 14:51:15 UTC
Created attachment 219906 [details]
patch to go into files dir of asciidoc

asciidoc 9.0.2 used \n in asciidoc.py 
9.0.4 uses \r\n 
This caused compiler errors in comms/fldigi (which I worked around for now)
Comment 1 Rainer Hurling freebsd_committer 2020-11-24 09:27:52 UTC
Created attachment 219917 [details]
Alternative patch to the lineend problem with comms/fldigi

Hi Diane,

I just looked into the github sources and it seems, that this changes with DEFAULT_NEWLINE [1] were introduced, because Python 3 has universal newlines mode enabled.

Eventually there is an alternive way to circumstance your build problem with comms/fldigi. There was another change in asciidoc.py [2], observed with Windows. Unix systems seem not to be affected, but let's try. 

Could you please try my attached patch instead of yours, rebuild and reinstall textproc/asciidoc, then try to build comms/fldigi and report back?

Thanks in advance,
Rainer (DH6BAG)


[1] https://github.com/asciidoc/asciidoc-py3/commit/fba22e4d8e7adf414aca34272f6b6938b6797cb6
[2] https://github.com/asciidoc/asciidoc-py3/commit/9b9dc0dba2f17bfd2c57c92dde29b5ca4d3d46c7
Comment 2 Diane Bruce freebsd_committer 2020-11-24 21:44:34 UTC
Your fix does not work.
I've narrowed it down to the use of -a toc
e.g. ascidoc -a toc file.txt
The bug is in template processing:
...
    elif name == 'template':
        if args not in config.sections:
            message.warning('%s: template does not exist' % syntax)
        else:
            result = []
            for line in config.sections[args]:
                line = subs_attrs(line)
                if line is not None:
                    result.append(line)
            result = '\n'.join(result)
#            result = DEFAULT_NEWLINE.

This hack works but is obviously the wrong fix. ;)
Comment 3 Diane Bruce freebsd_committer 2020-12-09 00:08:13 UTC
Any luck with this?
Comment 4 Rainer Hurling freebsd_committer 2020-12-10 11:55:02 UTC
(In reply to Diane Bruce from comment #3)
Sorry for the late answer. We are very busy at work :(

I am not sure, it a patch is needed any more? comms/fldigi builds and installs fine for me without patching asciidoc.py. Perhaps because of commit r557365?
Comment 5 Diane Bruce freebsd_committer 2020-12-11 01:13:44 UTC
(In reply to Rainer Hurling from comment #4)
The only reason fldigi compiles is I hacked in a sed to remove the extra \r which is not in the original Makefiles from vendor. It's a bug in asciidoc.
Comment 6 Rainer Hurling freebsd_committer 2020-12-11 06:18:29 UTC
(In reply to Diane Bruce from comment #5)
Ahh, ok. Seems I missed this hacking. Thanks for explanation.

So if I temporarily remove r556026, I can test your patch from comment #2 with textproc/asciidoc. I will test it this weekend.
Comment 7 Sunpoet Po-Chuan Hsieh freebsd_committer 2020-12-11 08:18:33 UTC
(In reply to Diane Bruce from comment #5)

Could you please try if [1][2] work for you?

From my point of view, I do not want to change the default behavior of asciidoc. And it's OK to patch fldigi 's Makefile to work with newer asciidoc. That can be submitted to upstream.

[1] https://github.com/asciidoc/asciidoc-py3/issues/154
[2] https://github.com/hoadlck/asciidoc-py3/commit/89ac0f48affb054226467b58f5af524ae0760d62
Comment 8 Rainer Hurling freebsd_committer 2020-12-11 17:57:07 UTC
Created attachment 220462 [details]
patch with newest

(In reply to Sunpoet Po-Chuan Hsieh from comment #7)

> Could you please try if [1][2] work for you?
> 
> From my point of view, I do not want to change the default
> behavior of asciidoc. And it's OK to patch fldigi 's
> Makefile to work with newer asciidoc. That can be submitted
> to upstream.
> 
> [1] https://github.com/asciidoc/asciidoc-py3/issues/154
> [2] https://github.com/hoadlck/asciidoc-py3/commit/89ac0f48affb054226467b58f5af524ae0760d62
Hi Sunpoet,

After patching textproce/asciidoc as suggested with [1][2], I rebuild this port and afterwards comms/fldigi. Both build and install fine, fldigi produces correct documentation output (tested with the beginners guide in html).

I attached the patched port textproc/asciidoc.

HTH,
Rainer
Comment 9 Diane Bruce freebsd_committer 2020-12-14 21:06:37 UTC
It looks perfect to me too ;) Yes I've been busy too so no worries!
Comment 10 Sunpoet Po-Chuan Hsieh freebsd_committer 2020-12-20 19:49:02 UTC
Committed. Thanks!
Comment 11 commit-hook freebsd_committer 2020-12-20 19:49:53 UTC
A commit references this bug:

Author: sunpoet
Date: Sun Dec 20 19:48:54 UTC 2020
New revision: 558767
URL: https://svnweb.freebsd.org/changeset/ports/558767

Log:
  Use config newline setting in system attribute evaluation

  - Bump PORTREVISION for package change

  It fixes comms/fldigi build without extra \r removal.

  Problems seen with inconsistent newlines in the Table Of Contents HTML pulled in
  from the configuration file. While the rest of the contents in the resulting
  HTML file honored the newline style configured by the user, this specific
  snippet of HTML always used "\r\n".

  This root of this problem existed for some time, but in earlier versions, the
  newline style was always "\n". The symptoms changed as a side effect of the
  issue "Extra line padding in source and literal blocks". In this issue, the
  newline style changed to "\r\n", and was noticed by users.

  Change the System Attribute Evaluation function to use the newline setting from
  the global "config" instead of using the default newline.

  PR:		251329
  Reported by:	db
  Obtained from:	https://github.com/asciidoc/asciidoc-py3/commit/8313e45cc78af30bb8df5d33311a7f2fdc50595c

Changes:
  head/textproc/asciidoc/Makefile
  head/textproc/asciidoc/files/patch-asciidoc.py