Using markup from an included file

2 ビュー (過去 30 日間)
Jan
Jan 2016 年 12 月 11 日
コメント済み: Jan 2016 年 12 月 13 日
My markup tends to be many more lines than my code, which makes debugging a nuisance. Is it possible to include it from a separate file (also nice for re-use)? I've tried:
%%Title
a = 1
<include> markup_01.m </include>
b = 2
It does publish the title and the MATLAB code including the workspace output, but the markup as defined in the file markup_01.m is included 'literally' in the comment format it is typed.

回答 (1 件)

Ahmet Cecen
Ahmet Cecen 2016 年 12 月 11 日
編集済み: Ahmet Cecen 2016 年 12 月 11 日
I don't believe you can achieve this as easily as you want. The only way I can think of is:
- Publish the markup file separately, then include the html output instead of the m file. However MATLAB will automatically escape the html tags when printing and will publish "[ampersand]lt;" and "[ampersand]gt;" instead of "<" and ">" which will break formatting.
- You will then have to write a third function that reads the final published html as text and replaces "[ampersand]lt;" occurrences with "<" and so forth.
  1 件のコメント
Jan
Jan 2016 年 12 月 13 日
Thanks Ahmet,
But I am not in the publishing business. I like the functionality to make my scripts easier to read. I think it would be added value for MATLAB if a dedicated markup include file would be supported, e.g. with a switch in the include statement e.g.
<include type="markup"> markup_01.m </include>.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeScripts についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by