Skip to content

Commit 66e05f7

Browse files
authored
sync: add marked indirection package (#4944)
Internal marked is a bit funky so, to paper over the differences, we introduce the indirection.
1 parent 87714b6 commit 66e05f7

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

tensorboard/webapp/third_party/BUILD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ tf_ts_library(
2222
"@npm//@tensorflow/tfjs-core",
2323
],
2424
)
25+
26+
tf_ts_library(
27+
name = "marked",
28+
srcs = ["marked.ts"],
29+
deps = [
30+
"@npm//@types/marked",
31+
"@npm//marked",
32+
],
33+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
==============================================================================*/
15+
/**
16+
* @fileoverview This is an marked interop that papers over the differences
17+
* within google internal repository and the external repository. Please depend
18+
* on this module instead of depending on the marked directly.
19+
*/
20+
import * as markedImport from 'marked';
21+
22+
// You cannot `export * from 'marked';` due to below error[1].
23+
// [1]: 'marked' uses 'export =' and cannot be used with 'export *'.
24+
export import marked = markedImport;

tensorboard/webapp/widgets/markdown_renderer/BUILD

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ tf_ng_module(
1515
"markdown_renderer_component.ng.html",
1616
],
1717
deps = [
18+
"//tensorboard/webapp/third_party:marked",
1819
"@npm//@angular/common",
1920
"@npm//@angular/core",
20-
"@npm//@types/marked",
21-
"@npm//marked",
2221
],
2322
)
2423

tensorboard/webapp/widgets/markdown_renderer/markdown_renderer_component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
SimpleChanges,
2323
ViewEncapsulation,
2424
} from '@angular/core';
25-
import {parse} from 'marked';
25+
import {marked} from '../../third_party/marked';
2626

2727
@Component({
2828
selector: 'markdown-renderer',
@@ -43,7 +43,7 @@ export class MarkdownRendererComponent implements OnChanges {
4343
if (changes['markdown']) {
4444
const markdownChange: SimpleChange = changes['markdown'];
4545
if (markdownChange.previousValue !== this.markdown) {
46-
this.markdownHTML = await parse(this.markdown);
46+
this.markdownHTML = await marked.parse(this.markdown);
4747
this.changeDetectorRef.detectChanges();
4848
}
4949
}

0 commit comments

Comments
 (0)