Skip to content

WolframResearch/codeformatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Brenton Bostick
Nov 1, 2022
42752a8 · Nov 1, 2022
Nov 1, 2022
Nov 1, 2022
Oct 6, 2022
Oct 18, 2022
Oct 17, 2022
Feb 7, 2022
Sep 1, 2022
Feb 5, 2020
Dec 9, 2021
Feb 5, 2020
Oct 7, 2022
Oct 21, 2022
Nov 12, 2019
Oct 7, 2022
Sep 16, 2020
Feb 7, 2022

Repository files navigation

CodeFormatter

CodeFormatter is a package that provides functionality for formatting Wolfram Language code.

Needs["CodeFormatter`"]

CodeFormat["If[a,f/@b,g/@c]"]
Out[2]= If[a,
            f /@ b
            ,
            g /@ c
        ]

Formatting the Wolfram Language from WTC 2020: Watch Video (youtube)

Setup

CodeFormatter depends on CodeParser paclet.

CodeFormatter and its dependencies are included in Mathematica 12.2 and above.

For older versions, install CodeFormatter paclet and dependencies from the public paclet server:

PacletInstall["CodeParser"]
PacletInstall["CodeFormatter"]

Build and install the CodeFormatter paclet locally

Using CodeFormatter

After CodeFormatter is installed, it can be used.

Needs["CodeFormatter`"]

CodeFormat["If[a,f/@b,g/@c]"]
Out[2]= If[a,
            f /@ b
            ,
            g /@ c
        ]

The input to CodeFormat may be a string, a File, or a list of bytes.

Troubleshooting

Make sure that the paclets can be found on your system:

Needs["CodeFormatter`"]

and try a basic example:

CodeFormat["If[a, b, c]"]