Skip to content

Commit

Permalink
feat(release): first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yisraelx committed Jan 1, 2017
0 parents commit c93483f
Show file tree
Hide file tree
Showing 42 changed files with 1,921 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# NodeJs
*.log
npm-debug.log*
node_modules

# IDE
.idea
.vscode

# Build
lib
bundles
demo/build
tmp

# Report
coverage
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: node_js
sudo: false
node_js:
- '6.6.0'
cache:
directories:
- node_modules
notifications:
email: false
branches:
only:
- master
before_script:
- npm prune
script:
- npm run lint
- npm run test
- npm run coverage:check
- npm run build
after_success:
- npm run coverage:report
- npm run semantic-release
branches:
except:
- /^v\d+\.\d+\.\d+$/
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright © 2016 Yisrael Eliav

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
151 changes: 151 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Angular 2 Markdown Module based on [Showdown library](https://github.com/showdownjs/showdown).
[![Travis build](https://travis-ci.org/yisraelx/ng2-md.svg?branch=master)](https://travis-ci.org/yisraelx/ng2-md)
[![Codecov coverage](https://codecov.io/github/yisraelx/ng2-md/coverage.svg?branch=master)](https://codecov.io/github/yisraelx/ng2-md)
[![Version](https://img.shields.io/npm/v/ng2-md.svg)](https://www.npmjs.com/package/ng2-md)
[![MIT License](https://img.shields.io/npm/l/ng2-md.svg)](https://github.com/yisraelx/ng2-md/blob/master/LICENSE)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

## Demo
- Online demo - [try](http://yisraelx.github.io/ng2-md)
- Local demo - [source](https://github.com/yisraelx/ng2-md/blob/master/demo)

## Install
```bash
$ npm install --save ng2-md
# and install peer dependencies
$ npm install --save @angular/core @angular/http showdown
```

## Use
#### Setup
```javascript
import { NgModule } from '@angular/core';
import { MdModule } from 'ng2-md';

@NgModule({
imports: [ MdModule ]
})
export class AppModule{}
```
### MdDirective
#### Binding
```javascript
import { IConverterOptions } from 'ng2-md';
// ...
text: string = `
# h1
## h2
`;
options: IConverterOptions = {...}
// ...
```
```html
<md [value]="text"><md>
```
```html
<md [value]="text" [options]="options"><md>
```
```html
<div [md]="text" [options]="options"><div>
```
#### Content
```html
<md>
# H1
## H2
<md>
```
```html
<md [options]="{...} as IConverterOptions">
# H1
## H2
<md>
```
Note: _there is a problem in content unescaped "{" and "}" (use html code)._

### Options
```javascript
import { IConverterOptions } from 'ng2-md';
// ...
options:IConverterOptions = {...};
//...
```
```html
<md [options]="options"># abc</md>
```
```html
<md [omitExtraWLInCodeBlocks]="options.omitExtraWLInCodeBlocks" [noHeaderId]="options.noHeaderId" [prefixHeaderId]="options.prefixHeaderId" [parseImgDimensions]="options.parseImgDimensions" [headerLevelStart]="options.headerLevelStart" [literalMidWordUnderscores]="options.literalMidWordUnderscores" [strikethrough]="options.strikethrough" [tables]="options.tables" [tablesHeaderId]="options.tablesHeaderId" [ghCodeBlocks]="options.ghCodeBlocks" [tasklists]="options.tasklists" [smoothLivePreview]="options.smoothLivePreview" [trimEachLine]="options.trimEachLine"># abc</md>
```
### Trim each line
```html
<md trimEachLine="space"> # abc </md> // <md><h1>abc</h1></md>
```
```html
<md trimEachLine="tab">\t# abc\t</md> // <md><h1>abc</h1></md>
```
both tab and space
```html
<md trimEachLine>\t # abc\t </md> // <md><h1>abc</h1></md>
```
### Load .md file (SrcDirective)
```html
<md src="README.md"></md>
```
```html
<md src="README.md" [options]="{...} as IConverterOptions"></md>
```

### Pipe
```javascript
import { IConverterOptions } from 'ng2-md';
// ...
text: string = `
# h1
## h2
`;
options: IConverterOptions = {...}
// ...
```
```html
{{ text | md }}
```
```html
{{ text | md:options }}
```

### Provider
```javascript
import { MdConverter } from 'ng2-md';

class Some{
constructor(mdConverter: MdConverter){
console.log(mdConverter.makeHtml("..."));
}
}
```

### Default converter options
the default options is the showdown default options
```javascript
import { NgModel } from '@angular/core';
import { ConverterOptions, BaseConverterOptions } from 'ng2-md';
export class MyConverterOptions extends ConverterOptions{
constructor(){
super({...});
}
}
@NgModel({
providers:[
{provide: ConverterOptions, useClass: MyConverterOptions},
]
})
export class AppModule{}
```

## Credits
This library based on [Showdown library](https://github.com/showdownjs/showdown)

## License
Copyright © 2016 [Yisrael Eliav](https://github.com/yisraelx),
Licensed under the [MIT license](https://github.com/yisraelx/ng2-md/blob/master/LICENSE).
20 changes: 20 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Clone
```bash
$ git clone https://github.com/yisraelx/ng2-md.git
```
### Install
```bash
$ npm install
```
### Run
```bash
$ npm run demo
# or
$ ../node_modules/.bin/webpack-dev-server
```
### Build
```bash
$ npm run build:demo
# or
$ ../node_modules/.bin/webpack
```
33 changes: 33 additions & 0 deletions demo/src/app/app.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.app-title {
width: 100%;
text-align: center;
}

md-sidenav {
width: 30%;
text-align: center;
}

.page {
height: calc(90%);
}

.content {
display: flex;
height: 100%;
}

md, textarea {
height: 100%;
overflow-y: scroll;
border: none;
padding: 10px;
}

.left, .right {
display: flex;
flex-direction: column;
justify-content: center;
flex: 1;
padding: 1rem;
}
40 changes: 40 additions & 0 deletions demo/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<md-sidenav-layout fullscreen>
<md-sidenav #start>
<md-nav-list>
<div *ngFor="let key of keys(options)">
<md-slide-toggle *ngIf="isType(options[key],'boolean')" class="nav-item-center" md-list-item [(ngModel)]="options[key]">{{key}}
</md-slide-toggle>
<md-input type="number" *ngIf="isType(options[key],'number')" class="nav-item-center" md-list-item [(ngModel)]="options[key]"
placeholder="{{key}}"></md-input>
<md-input type="text" *ngIf="isType(options[key],'string')" class="nav-item-center" md-list-item [(ngModel)]="options[key]"
placeholder="{{key}}"></md-input>
</div>
<hr/>
</md-nav-list>
<hr/>
<button md-button (click)="start.close()">CLOSE</button>
</md-sidenav>
<div class="page">
<md-toolbar color="primary">
<button md-icon-button (click)="start.open()">
<md-icon class="md-24">menu</md-icon>
</button>
<h1 class="app-title">{{title}}</h1>
</md-toolbar>
<div class="content">
<div class="left">
<textarea [(ngModel)]="md"></textarea>
</div>
<div class="right">
<md [value]="md" [trimEachLine]="options.trimEachLine" [omitExtraWLInCodeBlocks]="options.omitExtraWLInCodeBlocks"
[noHeaderId]="options.noHeaderId" [prefixHeaderId]="options.prefixHeaderId" [parseImgDimensions]="options.parseImgDimensions"
[headerLevelStart]="options.headerLevelStart" [literalMidWordUnderscores]="options.literalMidWordUnderscores"
[strikethrough]="options.strikethrough" [tables]="options.tables" [tablesHeaderId]="options.tablesHeaderId"
[ghCodeBlocks]="options.ghCodeBlocks" [tasklists]="options.tasklists" [smoothLivePreview]="options.smoothLivePreview"></md>
</div>
</div>
</div>
</md-sidenav-layout>
<a href="https://github.com/yisraelx/ng2-md"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>
43 changes: 43 additions & 0 deletions demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Component } from '@angular/core';
import { IConverterOptions } from '../../../src';

@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

title = 'Angular 2 Markdown Demo!';
md: string = `## hello markdown!
\`\`\`js
let a = 1;
let b = 2;
let sum = a+b;
console.log(\`sum: \${sum}\`);
\`\`\``;

options: IConverterOptions = {
omitExtraWLInCodeBlocks: true,
noHeaderId: true,
prefixHeaderId: true,
parseImgDimensions: true,
headerLevelStart: 1,
literalMidWordUnderscores: true,
strikethrough: true,
tables: true,
tablesHeaderId: true,
ghCodeBlocks: true,
tasklists: true,
smoothLivePreview: true,
trimEachLine: 'space'
};

keys(obj: Object) {
return Object.keys(obj);
}

isType(value: any, type: string) {
return typeof value === type;
}
}
21 changes: 21 additions & 0 deletions demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { MaterialModule } from '@angular/material';
import { AppComponent } from './app.component';
import { MdModule } from '../../../src';

@NgModule({
imports: [
BrowserModule,
FormsModule,
MaterialModule.forRoot(),
MdModule
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
})
export class AppModule {
}
Binary file added demo/src/favicon.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions demo/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<base href="/">
<title>Angular 2 Markdown Demo!</title>
<meta charset="UTF-8">
<meta name="description" content="Angular 2 Markdown Demo!">
<meta name="keywords" content="ng2,ng2-markdown,ng2-showdown,angular2,angular2-md,angular2-markdown,angular2-showdown,markdown,md,showdown">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
8 changes: 8 additions & 0 deletions demo/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app/app.module';
import './styles.css';
if (process.env.ENV === 'production') {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
Loading

0 comments on commit c93483f

Please sign in to comment.