Skip to content

Commit

Permalink
move human_readable_url function into utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirudennis committed Aug 7, 2024
1 parent 164c09e commit d3cc63c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 3 additions & 10 deletions textile/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
from textile.regex_strings import (align_re_s, cls_re_s, pnct_re_s,
regex_snippets, syms_re_s, table_span_re_s)
from textile.utils import (decode_high, encode_high, encode_html, generate_tag,
has_raw_text, is_rel_url, is_valid_url, list_type,
normalize_newlines, parse_attributes, pba)
has_raw_text, human_readable_url, is_rel_url,
is_valid_url, list_type, normalize_newlines,
parse_attributes, pba)
from textile.objects import Block, Table

try:
Expand Down Expand Up @@ -139,14 +140,6 @@ def make_glyph_replacers(html_type, uid, glyph_defs):
for (regex_obj, replacement) in pre_result]


def human_readable_url(url):
if "://" in url:
url = url.split("://")[1]
elif ":" in url:
url = url.split(":")[1]
return url


class Textile(object):
restricted_url_schemes = ('http', 'https', 'ftp', 'mailto')
unrestricted_url_schemes = restricted_url_schemes + (
Expand Down
8 changes: 8 additions & 0 deletions textile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ def has_raw_text(text):
return r != ''


def human_readable_url(url):
if "://" in url:
url = url.split("://")[1]
elif ":" in url:
url = url.split(":")[1]
return url


def is_rel_url(url):
"""Identify relative urls."""
(scheme, netloc) = urlparse(url)[0:2]
Expand Down

0 comments on commit d3cc63c

Please sign in to comment.