Skip to content

Disable heading IDs - #1190

Merged
styfle merged 15 commits into
markedjs:masterfrom
8fold:optional-heading-ids
Apr 3, 2018
Merged

Disable heading IDs#1190
styfle merged 15 commits into
markedjs:masterfrom
8fold:optional-heading-ids

Conversation

@joshbruce

@joshbrucejoshbruce commented Mar 31, 2018

Copy link
Copy Markdown
Member

Marked version: 0.3.19

Markdown flavor: n/a

Description

PR adds functionality to disable header IDs.

This is also related to work being performed on #1160.

For some reason testing options does not work in isolation.

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

  • Draft GitHub release notes have been updated.
  • CI is green (no forced merge required).
  • Merge PR

@joshbruce
joshbruce requested review from UziTech and styfleMarch 31, 2018 18:20
@styfle

Copy link
Copy Markdown
Member

You should also add this to the documentation so users are aware of this feature.

@UziTech

Copy link
Copy Markdown
Member

You should always create new branches from master to avoid including changes from other PRs

@UziTechUziTech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR should only contain changes to lib/marked.js

@joshbruce

Copy link
Copy Markdown
MemberAuthor

@styfle: Updated documentation. Maybe I should make that a separate PR given the review from @UziTech.

@UziTech: Believe it or not, I actually did branch off from master; I just did the same --save-dev from the other PR. Our test harness uses min; therefore, to get running tests I'm pretty sure there has to be updates to that file as well. Will put together some other PRs I think might cover the comments...sorry for the multiples and possible closings.

@joshbruce

Copy link
Copy Markdown
MemberAuthor

See #1192 and #1193

@UziTechUziTech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I saw the integration tests and assumed you had included changes from #1160

I was thinking integration tests would be more for testing specs and making sure marked works in different environments. I think this should just require a unit test on the renderer.

@joshbruce

joshbruce commented Apr 2, 2018

Copy link
Copy Markdown
MemberAuthor

@UziTech: Think I follow what you're asking, though not sure if I could do it easily. I'm adding this functionality to test the headers for CommonMark as none of the examples use IDs; so, the capability will be in the integration test suite at some point.

Will see what I can do on the more unit-test side of the house.

@UziTech

Copy link
Copy Markdown
Member

Ya that is fine if this option is used in the integration tests, but there is no need to have an integration test specifically for this feature.

The way I see integration tests is if a feature needs to test multiple parts of the software (and possibly the platform) than it should have an integration test (e.g. spec tests need to test the whole application; lexing, parsing, and rendering)

This feature only affects the rendering so it could be a unit test something like:

it('should add header ids by default',function(){varrederer=newmarked.Renderer(marked.defaults);varheader=rederer.heading('test',1,'test');expect(header).toBe('<h1 id="test">test</h1>\n');});it('should ignore header ids',function(){varrederer=newmarked.Renderer({headerIds: false});varheader=rederer.heading('test',1,'test');expect(header).toBe('<h1>test</h1>\n');});

@joshbruce

joshbruce commented Apr 2, 2018

Copy link
Copy Markdown
MemberAuthor

I believe we've covered all the comments and a little beyond.

  1. Uses unit tests instead of integration tests.
  2. Documentation updated (including some things that were missing and ordering them alphabetically in the code and the docs).
  3. Contributor checklist updated.

If we merge this, I will close #1192 and #1193. Then I should be able to go back to #1160 to handle the failing header things, which should then only have things that are actually broken remaining.

Comment threadpackage.json Outdated
"glob-to-regexp": "0.3.0",
"html-differ": "^1.3.4",
"jasmine": "^3.1.0",
"jasmine2-custom-message": "^0.9.0",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these are not needed for this PR

Comment threadtest/unit/marked-spec.js Outdated

describe('Test heading ID functionality', function() {
it('should add id attribute by default', function() {
var renderer = new sut.Renderer(sut.defaults);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we change sut to something like markedUnderTest or something like that? It feels very unintuitive that these defaults are coming from marked.

I feel like the only reason to distinguish the "system under test" is if we would need the same system not under test. (e.g. Jasmine testing Jasmine with Jasmine) I can't think of a reason we would ever need that.

Comment threadtest/integration/marked-spec.js Outdated
var marked = require('../../marked.min.js');
var HtmlDiffer = require('html-differ').HtmlDiffer,
htmlDiffer = new HtmlDiffer();
var since = require('jasmine2-custom-message');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are not needed

Comment threadlib/marked.js
breaks: false,
gfm: true,
headerPrefix: '',
headerIds: true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

'I' comes before 'P'

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Good catch...funny enough, I got it right in the table. :)

@UziTechUziTech left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should remove the package-lock.json changes.

Are we supposed to be including marked.min.js changes in PRs? or is that supposed to wait for a release?

#1192 seems to duplicate a lot of these changes. Should we do those changes in this PR?

@joshbruce

joshbruce commented Apr 3, 2018

Copy link
Copy Markdown
MemberAuthor
  1. Removed the package-lock file entirely.
  2. I had to do it because initially our test harness worked off min. We've also done PR merges with it changed in the past. I don't think it necessarily has to wait for a release...keeps us with the min reflects master mentality.
  3. Yes. If we approve this I will close Alphabetize options & update table docs #1192 and Add libraries and modify integration tests #1193 per comment: Disable heading IDs #1190 (comment)

Comment threadpackage.json Outdated
"eslint": "^4.15.0",
"eslint-config-standard": "^11.0.0-beta.0",
"eslint-plugin-import": "^2.8.0",
"eslint": "^4.19.1",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are you updating dev dependencies? This should be in a different PR in my opinion.

Comment threadpackage.json Outdated
"showdown": "*",
"uglify-js": "^3.3.10"
"markdown-it": "^8.4.1",
"showdown": "^1.8.6",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are these updated?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Not intentional.

Will try to reset manually.

screen shot 2018-04-03 at 12 02 41 pm

Comment threadpackage-lock.json Outdated
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz",
"integrity": "sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==",
"version": "5.5.3",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you revert this file too?

zhenalexfan pushed a commit to zhenalexfan/MarkdownHan that referenced this pull request Nov 8, 2021
* Add option to disable heading ids
* Alphabetize and add options to docs
Sign up for freeto 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.

3 participants

@joshbruce@styfle@UziTech