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

Disable heading IDs #1190

Merged
merged 15 commits into from
Apr 3, 2018
Merged

Disable heading IDs #1190

merged 15 commits into from
Apr 3, 2018

Conversation

joshbruce
Copy link
Member

@joshbruce joshbruce commented Mar 31, 2018

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

@styfle
Copy link
Member

styfle commented Apr 1, 2018

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

@UziTech
Copy link
Member

UziTech commented Apr 2, 2018

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

Copy link
Member

@UziTech UziTech left a comment

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
Member Author

@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
Member Author

See #1192 and #1193

Copy link
Member

@UziTech UziTech left a comment

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
Copy link
Member Author

joshbruce commented Apr 2, 2018

@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
Member

UziTech commented Apr 2, 2018

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 () {
  var rederer = new marked.Renderer(marked.defaults);
  var header = rederer.heading('test', 1, 'test');
  expect(header).toBe('<h1 id="test">test</h1>\n');
});

it('should ignore header ids', function () {
  var rederer = new marked.Renderer({ headerIds: false });
  var header = rederer.heading('test', 1, 'test');
  expect(header).toBe('<h1>test</h1>\n');
});

@joshbruce
Copy link
Member Author

joshbruce commented Apr 2, 2018

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.

package.json Outdated
"jasmine": "^3.1.0",
"jasmine2-custom-message": "^0.9.0",
Copy link
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


describe('Test heading ID functionality', function() {
it('should add id attribute by default', function() {
var renderer = new sut.Renderer(sut.defaults);
Copy link
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.

@@ -1,4 +1,7 @@
var marked = require('../../marked.min.js');
var HtmlDiffer = require('html-differ').HtmlDiffer,
htmlDiffer = new HtmlDiffer();
var since = require('jasmine2-custom-message');
Copy link
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

lib/marked.js Outdated
breaks: false,
gfm: true,
headerPrefix: '',
headerIds: true,
Copy link
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
Member Author

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. :)

Copy link
Member

@UziTech UziTech left a comment

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
Copy link
Member Author

joshbruce commented Apr 3, 2018

  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)

package.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
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.

package.json Outdated
"showdown": "*",
"uglify-js": "^3.3.10"
"markdown-it": "^8.4.1",
"showdown": "^1.8.6",
Copy link
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
Member Author

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

"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
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 free to 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