Title: fix: parse_inline drops links at position 0 and marks() loses href by ASRagab · Pull Request #36 · ma2za/python-substack · GitHub
Open Graph Title: fix: parse_inline drops links at position 0 and marks() loses href by ASRagab · Pull Request #36 · ma2za/python-substack
X Title: fix: parse_inline drops links at position 0 and marks() loses href by ASRagab · Pull Request #36 · ma2za/python-substack
Description: Summary Two bugs in inline link handling that cause all links created via from_markdown() to have null hrefs, and links at the start of a line to be silently dropped. Bug 1: Links at position 0 are dropped parse_inline() skips links that start at position 0 in the text. The image-exclusion check: if match.start() > 0 and text[match.start()-1:match.start()+1] != "![": Short-circuits to False when match.start() == 0, causing the link to be skipped entirely. Fix: Check match.start() == 0 or text[match.start() - 1] != "!" instead. Repro: parse_inline('[GPT](https://openai.com/)') # Before: [{'content': '[GPT](https://openai.com/)'}] # raw text, not a link # After: [{'content': 'GPT', 'marks': [{'type': 'link', 'attrs': {'href': 'https://openai.com/'}}]}] Bug 2: All link hrefs are null parse_inline() returns marks with the structure {'type': 'link', 'attrs': {'href': url}}, but marks() reads from mark.get('href') at the top level — missing the nested attrs entirely. Fix: Fall back to mark.get('attrs', {}).get('href') when top-level href is not present. This preserves backward compatibility with the top-level format shown in the README examples. Repro: post = Post('Test', '', user_id=1) post.from_markdown('Visit [Example](https://example.com)') body = json.loads(post.get_draft()['draft_body']) # Before: href is null for all links # After: href is 'https://example.com' Tests Added tests/substack/test_post.py with 6 tests covering: Links at position 0 Multiple links on same line Image exclusion (not parsed as link) Links in middle of text href from attrs (from_markdown path) href from top-level (manual add path) All tests pass. Pre-commit hooks (black, isort, trailing-whitespace, end-of-file-fixer) all pass.
Open Graph Description: Summary Two bugs in inline link handling that cause all links created via from_markdown() to have null hrefs, and links at the start of a line to be silently dropped. Bug 1: Links at position 0 are...
X Description: Summary Two bugs in inline link handling that cause all links created via from_markdown() to have null hrefs, and links at the start of a line to be silently dropped. Bug 1: Links at position 0 are...
Opengraph URL: https://github.com/ma2za/python-substack/pull/36
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9ecec3a8-2935-16ad-59f7-6e1547305066 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 940C:102A8A:4FE3687:6F723D2:6A50FA67 |
| html-safe-nonce | dcc2764fed99d20883bc41179d6f5ce600ac60853916d43bdebb4fb0c2233179 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDBDOjEwMkE4QTo0RkUzNjg3OjZGNzIzRDI6NkE1MEZBNjciLCJ2aXNpdG9yX2lkIjoiNjAyNjM0Mzg2NjkyMzI4NTA5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5c2a6114989a28c33c38181ee2d442083271f4bafc1a09586f85aa8a7466e07a |
| hovercard-subject-tag | pull_request:3346950208 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/ma2za/python-substack/pull/36/files |
| twitter:image | https://avatars.githubusercontent.com/u/1041016?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1041016?s=400&v=4 |
| og:image:alt | Summary Two bugs in inline link handling that cause all links created via from_markdown() to have null hrefs, and links at the start of a line to be silently dropped. Bug 1: Links at position 0 are... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/ma2za/python-substack git https://github.com/ma2za/python-substack.git |
| octolytics-dimension-user_id | 59370937 |
| octolytics-dimension-user_login | ma2za |
| octolytics-dimension-repository_id | 507708304 |
| octolytics-dimension-repository_nwo | ma2za/python-substack |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 507708304 |
| octolytics-dimension-repository_network_root_nwo | ma2za/python-substack |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8d836581d020676cc0ef4a83cd2fe17e4af02c3d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width