diff --git a/output/dot/templates.go b/output/dot/templates.go
index aca750441..8a00ec1c2 100644
--- a/output/dot/templates.go
+++ b/output/dot/templates.go
@@ -6,8 +6,8 @@ import (
"github.com/jessevdk/go-assets"
)
-var _Assets21532ae17ad95976ac467eeaeab81f2bb1d537e4 = "digraph \"{{ .Schema.Name }}\" {\n // Config\n graph [rankdir=TB, layout=dot, fontname=\"Arial\"];\n node [shape=record, fontsize=14, margin=0.6, fontname=\"Arial\"];\n edge [fontsize=10, labelfloat=false, splines=none, fontname=\"Arial\"];\n\n // Tables\n {{- range $i, $t := .Schema.Tables }}\n \"{{ $t.Name }}\" [shape=none, label=<
\n {{ $t.Name | html }} [{{ $t.Type | html }}] |
\n {{- range $ii, $c := $t.Columns }}\n {{ $c.Name | html }} [{{ $c.Type | html }}] |
\n {{- end }}\n
>];\n {{- end }}\n\n // Relations\n {{- range $j, $r := .Schema.Relations }}\n \"{{ $r.Table.Name }}\":{{ $c := index $r.Columns 0 }}{{ $c.Name }} -> \"{{ $r.ParentTable.Name }}\":{{ $pc := index $r.ParentColumns 0 }}{{ $pc.Name }} [dir=back, arrowtail=crow, {{ if $r.IsAdditional }}style=\"dashed\",{{ end }} taillabel=<>];\n {{- end }}\n}\n"
var _Assets5bd148e6149bb9adcdddfcf8cc46d6e3047dbe26 = "digraph \"{{ .Table.Name }}\" {\n // Config\n graph [rankdir=TB, layout=dot, fontname=\"Arial\"];\n node [shape=record, fontsize=14, margin=0.6, fontname=\"Arial\"];\n edge [fontsize=10, labelfloat=false, splines=none, fontname=\"Arial\"];\n\n // Tables\n \"{{ .Table.Name }}\" [shape=none, label=<\n {{ .Table.Name | html }} [{{ .Table.Type | html }}] |
\n {{- range $ii, $c := .Table.Columns }}\n {{ $c.Name | html }} [{{ $c.Type }}] |
\n {{- end }}\n
>];\n {{- range $i, $t := .Tables }}\n \"{{ $t.Name }}\" [shape=none, label=<\n {{ $t.Name | html }} [{{ $t.Type | html }}] |
\n {{- range $ii, $c := $t.Columns }}\n {{ $c.Name | html }} [{{ $c.Type | html }}] |
\n {{- end }}\n
>];\n {{- end }}\n\n // Relations\n {{- range $i, $r := .Relations }}\n \"{{ $r.Table.Name }}\":{{ $c := index $r.Columns 0 }}{{ $c.Name }} -> \"{{ $r.ParentTable.Name }}\":{{ $pc := index $r.ParentColumns 0 }}{{ $pc.Name }} [dir=back, arrowtail=crow, {{ if $r.IsAdditional }}style =\"dashed\",{{ end }} taillabel=<>];\n {{- end }}\n}\n"
+var _Assets21532ae17ad95976ac467eeaeab81f2bb1d537e4 = "digraph \"{{ .Schema.Name }}\" {\n // Config\n graph [rankdir=TB, layout=dot, fontname=\"Arial\"];\n node [shape=record, fontsize=14, margin=0.6, fontname=\"Arial\"];\n edge [fontsize=10, labelfloat=false, splines=none, fontname=\"Arial\"];\n\n // Tables\n {{- range $i, $t := .Schema.Tables }}\n \"{{ $t.Name }}\" [shape=none, label=<\n {{ $t.Name | html }} [{{ $t.Type | html }}] |
\n {{- range $ii, $c := $t.Columns }}\n {{ $c.Name | html }} [{{ $c.Type | html }}] |
\n {{- end }}\n
>];\n {{- end }}\n\n // Relations\n {{- range $j, $r := .Schema.Relations }}\n \"{{ $r.Table.Name }}\":{{ $c := index $r.Columns 0 }}{{ $c.Name }} -> \"{{ $r.ParentTable.Name }}\":{{ $pc := index $r.ParentColumns 0 }}{{ $pc.Name }} [dir=back, arrowtail=crow, {{ if $r.IsAdditional }}style=\"dashed\",{{ end }} taillabel=<>];\n {{- end }}\n}\n"
// Assets returns go-assets FileSystem
var Assets = assets.NewFileSystem(map[string][]string{"/": []string{"schema.dot.tmpl", "table.dot.tmpl"}}, map[string]*assets.File{
diff --git a/output/md/md.go b/output/md/md.go
index 7ce41e3e5..43407c110 100644
--- a/output/md/md.go
+++ b/output/md/md.go
@@ -182,10 +182,12 @@ func outputExists(s *schema.Schema, path string) bool {
func funcMap() map[string]interface{} {
return template.FuncMap{
"nl2br": func(text string) string {
- return strings.Replace(text, "\n", "
", -1)
+ r := strings.NewReplacer("\r\n", "
", "\n", "
", "\r", "
")
+ return r.Replace(text)
},
"nl2mdnl": func(text string) string {
- return strings.Replace(text, "\n", " \n", -1)
+ r := strings.NewReplacer("\r\n", " \n", "\n", " \n", "\r", " \n")
+ return r.Replace(text)
},
}
}
diff --git a/output/md/templates.go b/output/md/templates.go
index 142e014db..cecae5dde 100644
--- a/output/md/templates.go
+++ b/output/md/templates.go
@@ -11,19 +11,19 @@ var _Assetsac44302fb6150a621aa9d04a0350aac972bf7e18 = "# {{ .Table.Name }}\n\n##
// Assets returns go-assets FileSystem
var Assets = assets.NewFileSystem(map[string][]string{"/": []string{"index.md.tmpl", "table.md.tmpl"}}, map[string]*assets.File{
- "/": &assets.File{
- Path: "/",
- FileMode: 0x800001ed,
- Mtime: time.Unix(1531144283, 1531144283000000000),
- Data: nil,
- }, "/index.md.tmpl": &assets.File{
+ "/index.md.tmpl": &assets.File{
Path: "/index.md.tmpl",
FileMode: 0x1a4,
- Mtime: time.Unix(1531143680, 1531143680000000000),
+ Mtime: time.Unix(1531144926, 1531144926000000000),
Data: []byte(_Assets43889384df1c6f74d764c29d91b9d5637eb46061),
}, "/table.md.tmpl": &assets.File{
Path: "/table.md.tmpl",
FileMode: 0x1a4,
- Mtime: time.Unix(1531144283, 1531144283000000000),
+ Mtime: time.Unix(1531144926, 1531144926000000000),
Data: []byte(_Assetsac44302fb6150a621aa9d04a0350aac972bf7e18),
+ }, "/": &assets.File{
+ Path: "/",
+ FileMode: 0x800001ed,
+ Mtime: time.Unix(1531144926, 1531144926000000000),
+ Data: nil,
}}, "")
diff --git a/sample/mysql/README.md b/sample/mysql/README.md
index 82b9c1873..1c385f1f9 100644
--- a/sample/mysql/README.md
+++ b/sample/mysql/README.md
@@ -6,7 +6,7 @@
| ---- | ------- | ------- | ---- |
| [CamelizeTable](CamelizeTable.md) | 2 | | BASE TABLE |
| [comment_stars](comment_stars.md) | 6 | | BASE TABLE |
-| [comments](comments.md) | 6 | Comments
Multi-line table comment | BASE TABLE |
+| [comments](comments.md) | 6 | Comments
Multi-line
table
comment | BASE TABLE |
| [logs](logs.md) | 7 | audit log table | BASE TABLE |
| [post_comments](post_comments.md) | 7 | post and comments View table | VIEW |
| [posts](posts.md) | 7 | Posts table | BASE TABLE |
diff --git a/sample/mysql/comments.md b/sample/mysql/comments.md
index 2030bc95b..a214fef12 100644
--- a/sample/mysql/comments.md
+++ b/sample/mysql/comments.md
@@ -3,7 +3,9 @@
## Description
Comments
-Multi-line table comment
+Multi-line
+table
+comment
Table Definition
@@ -12,7 +14,7 @@ CREATE TABLE `comments` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`post_id` bigint(20) NOT NULL,
`user_id` int(11) NOT NULL,
- `comment` text NOT NULL COMMENT 'Comment\nMulti-line column comment',
+ `comment` text NOT NULL COMMENT 'Comment\nMulti-line\r\ncolumn\rcomment',
`created` datetime NOT NULL,
`updated` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -21,7 +23,7 @@ CREATE TABLE `comments` (
KEY `comments_post_id_user_id_idx` (`post_id`,`user_id`) USING HASH,
CONSTRAINT `comments_post_id_fk` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`),
CONSTRAINT `comments_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Comments\nMulti-line table comment'
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Comments\nMulti-line\r\ntable\rcomment'
```
@@ -34,7 +36,7 @@ CREATE TABLE `comments` (
| id | bigint(20) | | false | [logs](logs.md) | | |
| post_id | bigint(20) | | false | [comment_stars](comment_stars.md) | [posts](posts.md) | |
| user_id | int(11) | | false | [comment_stars](comment_stars.md) | [users](users.md) | |
-| comment | text | | false | | | Comment
Multi-line column comment |
+| comment | text | | false | | | Comment
Multi-line
column
comment |
| created | datetime | | false | | | |
| updated | datetime | | true | | | |
diff --git a/sample/mysql/post_comments.md b/sample/mysql/post_comments.md
index 8c657e12d..db48650ed 100644
--- a/sample/mysql/post_comments.md
+++ b/sample/mysql/post_comments.md
@@ -20,7 +20,7 @@ CREATE VIEW post_comments AS ((select `c`.`id` AS `id`,`p`.`title` AS `title`,`u
| id | bigint(20) | 0 | true | | | comments.id |
| title | varchar(255) | | false | | | posts.title |
| post_user | varchar(50) | | true | | | posts.users.username |
-| comment | text | | true | | | Comment
Multi-line column comment |
+| comment | text | | true | | | Comment
Multi-line
column
comment |
| comment_user | varchar(50) | | true | | | comments.users.username |
| created | datetime | | true | | | comments.created |
| updated | datetime | | true | | | comments.updated |
diff --git a/sample/mysql8/README.md b/sample/mysql8/README.md
index 82b9c1873..1c385f1f9 100644
--- a/sample/mysql8/README.md
+++ b/sample/mysql8/README.md
@@ -6,7 +6,7 @@
| ---- | ------- | ------- | ---- |
| [CamelizeTable](CamelizeTable.md) | 2 | | BASE TABLE |
| [comment_stars](comment_stars.md) | 6 | | BASE TABLE |
-| [comments](comments.md) | 6 | Comments
Multi-line table comment | BASE TABLE |
+| [comments](comments.md) | 6 | Comments
Multi-line
table
comment | BASE TABLE |
| [logs](logs.md) | 7 | audit log table | BASE TABLE |
| [post_comments](post_comments.md) | 7 | post and comments View table | VIEW |
| [posts](posts.md) | 7 | Posts table | BASE TABLE |
diff --git a/sample/mysql8/comments.md b/sample/mysql8/comments.md
index 317f1ec18..eb033f014 100644
--- a/sample/mysql8/comments.md
+++ b/sample/mysql8/comments.md
@@ -3,7 +3,9 @@
## Description
Comments
-Multi-line table comment
+Multi-line
+table
+comment
Table Definition
@@ -12,7 +14,7 @@ CREATE TABLE `comments` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`post_id` bigint(20) NOT NULL,
`user_id` int(11) NOT NULL,
- `comment` text NOT NULL COMMENT 'Comment\nMulti-line column comment',
+ `comment` text NOT NULL COMMENT 'Comment\nMulti-line\r\ncolumn\rcomment',
`created` datetime NOT NULL,
`updated` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -21,7 +23,7 @@ CREATE TABLE `comments` (
KEY `comments_post_id_user_id_idx` (`post_id`,`user_id`),
CONSTRAINT `comments_post_id_fk` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`),
CONSTRAINT `comments_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Comments\nMulti-line table comment'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Comments\nMulti-line\r\ntable\rcomment'
```
@@ -34,7 +36,7 @@ CREATE TABLE `comments` (
| id | bigint(20) | | false | [logs](logs.md) | | |
| post_id | bigint(20) | | false | [comment_stars](comment_stars.md) | [posts](posts.md) | |
| user_id | int(11) | | false | [comment_stars](comment_stars.md) | [users](users.md) | |
-| comment | text | | false | | | Comment
Multi-line column comment |
+| comment | text | | false | | | Comment
Multi-line
column
comment |
| created | datetime | | false | | | |
| updated | datetime | | true | | | |
diff --git a/sample/mysql8/post_comments.md b/sample/mysql8/post_comments.md
index 39989554d..e0363eda7 100644
--- a/sample/mysql8/post_comments.md
+++ b/sample/mysql8/post_comments.md
@@ -20,7 +20,7 @@ CREATE VIEW post_comments AS (select `c`.`id` AS `id`,`p`.`title` AS `title`,`u2
| id | bigint(20) | 0 | true | | | comments.id |
| title | varchar(255) | | false | | | posts.title |
| post_user | varchar(50) | | true | | | posts.users.username |
-| comment | text | | true | | | Comment
Multi-line column comment |
+| comment | text | | true | | | Comment
Multi-line
column
comment |
| comment_user | varchar(50) | | true | | | comments.users.username |
| created | datetime | | true | | | comments.created |
| updated | datetime | | true | | | comments.updated |
diff --git a/sample/postgres/README.md b/sample/postgres/README.md
index 0baac25a8..0a0119b07 100644
--- a/sample/postgres/README.md
+++ b/sample/postgres/README.md
@@ -6,7 +6,7 @@
| ---- | ------- | ------- | ---- |
| [users](users.md) | 6 | Users table | BASE TABLE |
| [posts](posts.md) | 8 | Posts table | BASE TABLE |
-| [comments](comments.md) | 6 | Comments
Multi-line table comment | BASE TABLE |
+| [comments](comments.md) | 6 | Comments
Multi-line
table
comment | BASE TABLE |
| [comment_stars](comment_stars.md) | 6 | | BASE TABLE |
| [logs](logs.md) | 7 | audit log table | BASE TABLE |
| [post_comments](post_comments.md) | 7 | post and comments View table | VIEW |
diff --git a/sample/postgres/comments.md b/sample/postgres/comments.md
index 800b377a7..1eea1dc77 100644
--- a/sample/postgres/comments.md
+++ b/sample/postgres/comments.md
@@ -3,7 +3,9 @@
## Description
Comments
-Multi-line table comment
+Multi-line
+table
+comment
## Columns
@@ -12,7 +14,7 @@ Multi-line table comment
| id | bigint | nextval('comments_id_seq'::regclass) | false | [logs](logs.md) | | |
| post_id | bigint | | false | [comment_stars](comment_stars.md) | [posts](posts.md) | |
| user_id | integer | | false | [comment_stars](comment_stars.md) | [users](users.md) | |
-| comment | text | | false | | | Comment
Multi-line column comment |
+| comment | text | | false | | | Comment
Multi-line
column
comment |
| created | timestamp without time zone | | false | | | |
| updated | timestamp without time zone | | true | | | |
diff --git a/test/my.sql b/test/my.sql
index 7b0525798..20c5d0de5 100644
--- a/test/my.sql
+++ b/test/my.sql
@@ -33,14 +33,14 @@ CREATE TABLE comments (
id bigint AUTO_INCREMENT,
post_id bigint NOT NULL,
user_id int NOT NULL,
- comment text NOT NULL COMMENT 'Comment\nMulti-line column comment',
+ comment text NOT NULL COMMENT 'Comment\nMulti-line\r\ncolumn\rcomment',
created datetime NOT NULL,
updated datetime,
CONSTRAINT comments_id_pk PRIMARY KEY(id),
CONSTRAINT comments_post_id_fk FOREIGN KEY(post_id) REFERENCES posts(id) MATCH SIMPLE,
CONSTRAINT comments_user_id_fk FOREIGN KEY(user_id) REFERENCES users(id) MATCH SIMPLE,
UNIQUE(post_id, user_id)
-) COMMENT = 'Comments\nMulti-line table comment';
+) COMMENT = 'Comments\nMulti-line\r\ntable\rcomment';
CREATE INDEX comments_post_id_user_id_idx ON comments(post_id, user_id) USING HASH;
CREATE TABLE comment_stars (
diff --git a/test/pg.sql b/test/pg.sql
index 4f3683a14..2bb1d879f 100644
--- a/test/pg.sql
+++ b/test/pg.sql
@@ -57,8 +57,8 @@ CREATE TABLE comments (
CONSTRAINT comments_user_id_fk FOREIGN KEY(user_id) REFERENCES users(id) MATCH SIMPLE,
UNIQUE(post_id, user_id)
);
-COMMENT ON TABLE comments IS E'Comments\nMulti-line table comment';
-COMMENT ON COLUMN comments.comment IS E'Comment\nMulti-line column comment';
+COMMENT ON TABLE comments IS E'Comments\nMulti-line\r\ntable\rcomment';
+COMMENT ON COLUMN comments.comment IS E'Comment\nMulti-line\r\ncolumn\rcomment';
CREATE INDEX comments_post_id_user_id_idx ON comments USING btree(post_id, user_id);