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

example code does not work (anymore): content is unchanged #85

Open
marko-knoebl opened this issue Nov 17, 2019 · 4 comments
Open

example code does not work (anymore): content is unchanged #85

marko-knoebl opened this issue Nov 17, 2019 · 4 comments

Comments

@marko-knoebl
Copy link

I've tried to use the example code from the readme.

When using @agentofuser/rehype-section version 1.0.5 the resulting output is the same as the input - no section elements are added for me.

When using version 0.1.2 it still works as expected.

Has the API changed?

I'll test this on a different computer tomorrow to verify this is independent of my local machine.

@marko-knoebl
Copy link
Author

I've found out how to get it working for me.

The readme has this line of code - which doesn't work:

var section = require('rehype-section');

I finally got it working via either:

var section = require('@agentofuser/rehype-section').default

or:

import sectionParent from '@agentofuser/rehype-section';
const section = sectionParent.default;

I'm pretty sure this unintentional.

Interestingly, the internal test case in test/section.test.ts has a different behaviour:

In the test I can either keep the existing line:

import section from '../src/.'

or I can replace it with:

const section = require('../src/.').default

So one kind of import is working as expected, the other one isn't.

@chengluyu
Copy link

Thank you! This saves my day. 😭

@felixfbecker
Copy link

I'm using

import section from '@agentofuser/rehype-section'

and am also experiencing this issue: content remains unchanged.

This should import the default import, but instead it gives an object with a default property:

{ default: [Function attacher] }

@av-2024
Copy link

av-2024 commented Feb 20, 2022

The code and type definitions for this package are still broken. I have to use this as a workaround to 1) get it to work at all and 2) get TypeScript to stop complaining:

import _rehypeSection from '@agentofuser/rehype-section'

const rehypeSection = (_rehypeSection as any).default

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

No branches or pull requests

4 participants