Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pandoc version detection in Makefile, so markdown-smart is used and double dashes don't get converted to single hyphens in the man page #32188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

t-nil
Copy link

@t-nil t-nil commented May 14, 2023

…hen or equal to 2

See yt-dlp/yt-dlp#7046

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense

What is the purpose of your pull request?

  • Bug fix

Description of your pull request and other information

The makefile had a hardcoded major version check of pandoc against 2. In my pandoc 3 installation the check failed and smart-markdown was not used, even though it is available. That caused double dashes to be rendered as single, long dashes.

This PR fixes the version check by numerically comparing the pandoc major version to be greater then or equal to 2.

@@ -15,7 +15,7 @@ PYTHON ?= /usr/bin/env python
SYSCONFDIR = $(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)

# set markdown input format to "markdown-smart" for pandoc version 2 and to "markdown" for pandoc prior to version 2
MARKDOWN = $(shell if [ `pandoc -v | head -n1 | cut -d" " -f2 | head -c1` = "2" ]; then echo markdown-smart; else echo markdown; fi)
MARKDOWN = $(shell if [ `pandoc -v | head -n1 | cut -d" " -f2 | head -c1` -ge "2" ]; then echo markdown-smart; else echo markdown; fi)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously not related to the issue, but this can be done just in POSIX shell, under the assumption that the major version is the digit string at the start of the second word in the version:

Suggested change
MARKDOWN = $(shell if [ `pandoc -v | head -n1 | cut -d" " -f2 | head -c1` -ge "2" ]; then echo markdown-smart; else echo markdown; fi)
MARKDOWN = $(shell printf 'markdown%s\n' "$(pandoc -v | { read -r _ x; x=${x%%[^0-9]*}; [ "${x:-0}" -ge 2 ] && printf '%s' "-smart"; })")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants