showdownjs / ng-showdown Goto Github PK
View Code? Open in Web Editor NEWAngular integration for Showdown
License: BSD 3-Clause "New" or "Revised" License
Angular integration for Showdown
License: BSD 3-Clause "New" or "Revised" License
We use angular-sanitize
in the src, so it should be a dependency in the bower.json
.
Hello,
I am not sure if this is a ng-showdown issue or Showdown issue but how to enable sanitization is missing from the docs. I had to look at multiple issues and the code itself to realise this.
Here is the option: $showdownProvider.setOption('sanitize', true)
The error is simply:
15 10 2015 18:18:10.760:ERROR [framework.browserify]: bundle error
15 10 2015 18:18:10.760:ERROR [framework.browserify]: Error: Cannot find module 'showdown' from '../project/bower_components/ng-showdown/dist'
These are my installed packages
$ bower list
├─┬ ng-showdown#1.0.1
│ ├── angular#1.4.7 (1.5.0-build.4324+sha.469b14a available)
│ ├─┬ angular-sanitize#1.4.7 (1.5.0-build.4324+sha.469b14a available)
│ │ └── angular#1.4.7
│ └── showdown#1.2.3
A similar error was reported and fixed in showdown.
I'm running browserify in the Karma pipeline
paths = { test: [
//..
'./bower_components/ng-showdown/dist/ng-showdown.js',
//..
]};
config.set({
basePath: __dirname + '/../..',
files: paths.test,
exclude: [],
frameworks: ['browserify', 'jasmine'],
browsers: ['PhantomJS'],
reporters: ['progress', 'coverage'],
preprocessors: {
'bower_components/**/*js': ['browserify'],
'app/src/app.js': ['browserify', 'coverage'],
'app/src/**/*test.js': ['browserify', 'coverage']
},
coverageReporter: {
type: 'html',
dir: paths.dest.testCoverage
},
browserify: {
debug: true,
transform: ['babelify']
},
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
port: 9876,
singleRun: false
});
any ideas? Thanks!
Are there any plans to upgrade this tool for angular 2? Or is ng1 the final version?
I'm simply working on planning my upgrade strategy, and trying to discern both feasibility and timeline. showdownjs, and more specifically, ng-showdown, is an extremely integral part of my project, if not one of the most important parts of it.
If there are no plans to do it, are you open to accepting community contributions that get it ported to ng2? If you're not planning to do it, I may try to take the task upon myself.
iframes are inserted correctly, but when using it for a live preview, it reloads every time the input changes and makes the iframe disappear/reappear with every new character.
Hello,
Are there plans to write a documentation any soon?
Add in set flavor function into the $showdownProvider. This would be a new option.
Strikethroughs in code blocks formatted with strikethrough (rather than displaying bare symbols).
Example:
Code | Expected | Actual | Comment |
---|---|---|---|
~~text~~ |
Good so far | ||
`~~text~~` |
~~text~~ |
|
Strikethrough should not display |
`**text**` |
**text** |
**text** |
For example, bold works as expected |
Although the package.json has been updated, this release hasn't been published via NPM.
I'm trying to add extensions to showdown, and am using ng-showdown
to render markdown on my page. I'm a bit unclear about how this works; Assuming I've created and registered the extension...
$showdown.setOption('extension', ('myext', () => {
return {
type: 'lang',
regex: /markdown/g,
replace: 'showdown'
};
}));
How can I use this on my page without calling it directly? I'm rendering using the markdown-to-html
directive.
I've browsed through the documentation several times and am just not understanding this. I basically want to add some custom tags, and from what I gather that should be easy with the extensions system.
I noticed the 1.0.0-beta branch removes the angular support for showdown in the core module. I'm in agreeance with splitting out this into its own repo.
I can build this functionality out. Here's my plan:
@tivie What do you think of the name? (do you care?) Does this sound like a good plan?
Currently require('ng-showdown')
doesn't work because it'll load ./dist/ng-showdown.js
which is empty.
Can this either be pointed at the src file or the dist file get populated with a real build?
I have some options set with $showdownProvider.setOption('<property>', true);
. Some of them work, some act as though the option is not being set. (Have not tested extensively, so these are only the options I'm using).
Option: setOption('underline', true);
Markdown
__text__
Expected
Underlined "text" (does not display in GitHub)
Actual
"text"
Option: setOption('simpleLineBreaks', true);
Markdown
text
text
Expected
"text
text"
Actual
"text text"
(For sanity check purposes)
Option: setOption('tables', true);
Markdown
| Header1 | Header2 |
|:-------:|:-------:|
| itemA1 | itemA2 |
| itemB1 | itemB2 |
Result
Header1 | Header2 |
---|---|
itemA1 | itemA2 |
itemB1 | itemB2 |
Option: setOption('headerLevelStart', 2);
Markdown
# I'm a heading
Result (html)
<h2>I'm a heading</h2>
This is related to #14 and #17 , just adding it here so it doesn't get lost. See my comment on #17:
Ok, found the core issue why the code doesn't work for me: I am using full jQuery and not only the JQlite bundled with angular. In it seems element.html behave a bit differently there, which results in jQuery not outputting anything.
That means passing the result of $sce.trustAsHtml()
to element.html()
works with jqLite (the jQuery like implementation bundled with angular), but not with the full jQuery.
@SyntaxRules mentioned a fix he had in mind:
I want to add in one more fix for line 174. It will include passing the output straight to a directive, instead of using angular.element. Which will fix the problem @phw was having. I'm hoping to have it done tuesday.
I think there is some conflict with the directives.
The current documentation says one should use
<p markdown-to-html="mdScopeVariable"></p>
For me this fails, having a look at the code the model value in https://github.com/showdownjs/ng-showdown/blob/master/src/ng-showdown.js#L121 is always undefined.
Looks like the model is expected in sd-model-to-html
. However that doesn't work, either. Using both makes Angular complain about two directives requesting an isolated scope, using only sd-model-to-html
strangely also shows an undefined model.
Using angular 1.3.15
var app = angular.module('myAngularApp', ['ngRoute', 'ngAnimate', 'ui.bootstrap', 'ng-showdown']);
When I use that line, I get an uncaught error. Everything works fine if you remove the ng-showdown from the list (except showdown does not work).
I use the following list of other javascript files/libraries:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-route.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/1.2.1/ui-bootstrap-tpls.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.3.0/showdown.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ng-showdown/1.1.0/ng-showdown.min.js"></script>
I was able to make a custom extension, but I couldn't find how to compile the contained directives.
The given tag is replaced, but the resulting HTML is not processed by Angular.
How to compile the result with Angular? I don't know if it is even possible to define a compilation from .config(). Should the extension be included somewhere else?
Here is a test extension replacing &test
by '<simple-element></simple-element>
:
angular.module('myApp')
.config(['$showdownProvider', function($showdownProvider) {
myExt = function () {
return [{
type: 'output',
filter: function (text) {
var regex = /(<p>&test<\/p>)+/g;
text = text.replace(
regex,
'<simple-element>extension: ok, directive: NOT</simple-element>'
);
return text;
}
}];
};
$showdownProvider.loadExtension(myExt);
}]);
The simpleElement directive:
angular.module('myApp')
.directive('simpleElement', [function() {
return {
restrict: 'E',
replace: true,
template: '<div>Everything works!</div>'
}
}]);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.