Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion markdownify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def main(argv=sys.argv[1:]):
parser.add_argument('-a', '--autolinks', action='store_true',
help="A boolean indicating whether the 'automatic link' style "
"should be used when a 'a' tag's contents match its href.")
parser.add_argument('--default-title', action='store_false',
parser.add_argument('--default-title', action='store_true',
help="A boolean to enable setting the title of a link to its "
"href, if no title is given.")
parser.add_argument('--heading-style', default=UNDERLINED,
Expand Down
18 changes: 18 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from io import StringIO

import pytest

from markdownify.main import main


@pytest.mark.parametrize('args, title, expected_title', [
([], '', ''),
(['--default-title'], '', ' "https://example.com"'),
([], ' title="Example"', ' "Example"'),
(['--default-title'], ' title="Example"', ' "Example"'),
])
def test_default_title(args, title, expected_title, monkeypatch, capsys):
html = '<a href="https://example.com"%s>Example</a>' % title
monkeypatch.setattr('sys.stdin', StringIO(html))
main(args)
assert capsys.readouterr().out == '[Example](https://example.com%s)\n' % expected_title