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

Unable (or unclear how) to set showdown config #73

Open
Dhaulagiri opened this issue Oct 25, 2022 · 1 comment
Open

Unable (or unclear how) to set showdown config #73

Dhaulagiri opened this issue Oct 25, 2022 · 1 comment

Comments

@Dhaulagiri
Copy link
Contributor

Per the docs for ember-cli-showdown it should be possible to set global showdown config via an app's environment.js. However, these options don't appear to be passed along to showdown as part of the way showdown is invoked in field-guide.

I was able to make this work by doing something like this, but it's unclear if this is the best solution of if there is something else I'm missing here.

export default Controller.extend({
  fieldGuideConfig: config['field-guide'],
  showdownConfig: config['showdown'],
  renderedContent: computed('model.content', function() {
    const converter = new showdown.Converter(this.showdownConfig);
    return converter.makeHtml(this.model.content);
  })
})
@NullVoxPopuli
Copy link

NullVoxPopuli commented Jun 14, 2023

Thanks! I did this technique, too, and used my own show controller.

Here is my version though, because extend is from the dark ages 😅

import showdown from 'showdown';
import footnotes from 'showdown-ghost-footnotes';

import Controller from '@ember/controller';
import { cached } from '@glimmer/tracking';

import config from 'my-app/config/environment';

// Overrides: https://github.com/empress/field-guide/blob/master/addon/controllers/show.js
// see: https://github.com/empress/field-guide/issues/73
export default class Show extends Controller {
	fieldGuideConfig = config['field-guide'];

	@cached
	get renderedContent() {
		const converter = new showdown.Converter({ extensions: [footnotes] });
		return converter.makeHtml(this.model.content);
	}
}

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

2 participants