🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

matlab-publish-parser

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

matlab-publish-parser

The package parses the xml output of publish in MATLAB,.

2025.0.0
Maintainers
1

This package is used to parse the xml output of MATLAB publish, and this way facilitate deriving more advanced documentation that contain MATLAB code with matching output and figures.

Usage

MATLAB processing

Write the code that you want to create output from as a MATLAB publish document. The package will parse the code, and separate the different cells. The package will separate documentation, executed code, console output and figures.

In MATLAB process the created file (in this case example.m) using publish:

publish('example.m',...
        'format', 'xml',...
        'imageFormat', 'epsc',...
        'outputDir', 'gen/',...
        'catchError', false);  % Fail on thrown exception

This will produce the file gen/example.xml

Python Processing

Usage:

import matlab_publish_parser as mpp

mf = matlab_publish_parser.parse(Path('example.xml'))

print(mf.filename)  # The name of the processed file
print(mf.output_dir)  # Directory for generated files
for c in mf.cells:
  print(c.title)  # Title of cell
  print(c.code)  # Executed code in cell
  print(c.output)  # Console output from cell
  ...

Explore the object to figure out what has been extracted.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts