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

Added anchor without link to internalparsertest #3

Merged
merged 3 commits into from
Mar 6, 2023

Conversation

tyson-nw
Copy link
Contributor

Sorry if this is the wrong way to do this, it is my first pull request on a project I don't own.

Basically, the functionality I am looking for is when an internal link only includes the anchor, in the case of [[#anchor]] or [[#anchor|title]] that it creates an anchor link that points to an anchor in the current page. Used in conjunction with League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension it should allow you to link to heading anchors within the page.

I am unsure how to write that myself, so I added the tests that would check for it.

@elazar elazar self-assigned this Jan 29, 2023
@elazar elazar added the bug Something isn't working label Jan 29, 2023
@elazar
Copy link
Owner

elazar commented Jan 30, 2023

@tyson-nw I've pushed a change to this PR that appears to satisfy the test. Let me know if it works for you; if so, I'll merge it and tag a new release.

@tyson-nw
Copy link
Contributor Author

It is still not parsing anchor links. For example, this bit of markdown

## Rolls
When you "make a roll" you roll a [[#d12]] and add a bonus. The bonus is the total of the [[#Stat]] being used for the roll, the [[#Skill]] being used for the roll, and any [[#Specialty]] that the [[#Game Master]] agrees applies. Then you compare the roll to the [[#Target Number]], if it is higher the roll succeeds. If the roll is lower or equal to the [[#Target Number]], the roll fails.

It is producing

<h2><a id="content-rolls" href="#content-rolls" class="heading-permalink" aria-hidden="true" title="Permalink"></a>Rolls</h2>
<p>When you &quot;make a roll&quot; you roll a [[#d12]] and add a bonus. The bonus is the total of the [[#Stat]] being used for the roll, the [[#Skill]] being used for the roll, and any [[#Specialty]] that the [[#Game Master]] agrees applies. Then you compare the roll to the [[#Target Number]], if it is higher the roll succeeds. If the roll is lower or equal to the [[#Target Number]], the roll fails.</p>

instead of

<h2><a id="content-rolls" href="#content-rolls" class="heading-permalink" aria-hidden="true" title="Permalink"></a>Rolls</h2>
<p>When you &quot;make a roll&quot; you roll a <a href='#content-d12'>d12</a> and add a bonus. The bonus is the total of the <a href='#content-stat'>Stat</a> being used for the roll, the <a href='#content-skill'>Skill</a> being used for the roll, and any <a href='#content-specialty>Specialty</a> that the <a href='#content-game-master'>Game Master</a> agrees applies. Then you compare the roll to the <a href='#content-target-number'>Target Number</a>, if it is higher the roll succeeds. If the roll is lower or equal to the <a href='#content-targer-number'>Target Number</a>, the roll fails.</p>

I am using the use League\CommonMark\Environment\Environment; config with the use League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkExtension; and use League\CommonMark\Extension\HeadingPermalink\HeadingPermalinkRenderer;

$config = [
            'heading_permalink' => [
                'html_class' => 'heading-permalink',
                'id_prefix' => 'content',
                'fragment_prefix' => 'content',
                'insert' => 'before',
                'min_heading_level' => 1,
                'max_heading_level' => 6,
                'title' => 'Permalink',
                'symbol' => "",
            ],
];

@elazar
Copy link
Owner

elazar commented Feb 5, 2023

@tyson-nw Thanks for the test case. I've pushed another change that I think should fix your problem. Please let me know if it works.

@elazar elazar merged commit affeef6 into elazar:main Mar 6, 2023
@elazar
Copy link
Owner

elazar commented Mar 6, 2023

@tyson-nw Per the contributing guidelines, because this issue has been inactive for 30 days, I have closed it. I've merged the fixes on this branch and included them in the 2.1.0 release. If you have any further problems with this functionality, please file a new issue or pull request. Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants