---
title: "Overview"
description: "Choose between the comark and mdast adapters, and learn what the code adapter adds."
canonical_url: "https://diglot.sh/adapters/overview"
---
# Overview

> Choose between the comark and mdast adapters, and learn what the code adapter adds.

An adapter connects diglot to a markdown parser. It does two jobs: it extracts segments from a document, and it applies translations back to the document. The core never parses markdown itself, so each adapter decides how a parser's tree maps to [segments](https://diglot.sh/guide/concepts/segments).

<table>
<thead>
  <tr>
    <th>
      Package
    </th>
    
    <th>
      Parser
    </th>
    
    <th>
      Use it for
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a href="https://diglot.sh/adapters/comark">
        <code>
          @diglot/comark
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://comark.dev" rel="nofollow">
        comark
      </a>
    </td>
    
    <td>
      Comark documents, and <code>
        .navigation.yml
      </code>
      
       files
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://diglot.sh/adapters/mdast">
        <code>
          @diglot/mdast
        </code>
      </a>
    </td>
    
    <td>
      remark with <code>
        remark-gfm
      </code>
      
      , <code>
        remark-frontmatter
      </code>
      
       and <code>
        remark-mdc
      </code>
    </td>
    
    <td>
      Astro, Docusaurus, Starlight or plain markdown sources
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://diglot.sh/adapters/code">
        <code>
          @diglot/code
        </code>
      </a>
    </td>
    
    <td>
      A tokenizer per language
    </td>
    
    <td>
      The comments of fenced code blocks, used by both adapters
    </td>
  </tr>
</tbody>
</table>

## Choosing one

Set `parser` in the [configuration](https://diglot.sh/guide/how-to/configure) to `comark` (the default) or `mdast`. The CLI and the Action then use it for every markdown file of every source. `.navigation.yml` files are always handled by the comark package.

The two adapters return the same segments, with the same hashes, for the same document, so records stay valid if you switch. They differ in what they give you when you apply translations:

<table>
<thead>
  <tr>
    <th>
      
    </th>
    
    <th>
      comark
    </th>
    
    <th>
      mdast
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Input to <code>
        extract
      </code>
    </td>
    
    <td>
      A parsed document from <code>
        parse(source)
      </code>
    </td>
    
    <td>
      The markdown string
    </td>
  </tr>
  
  <tr>
    <td>
      Output of <code>
        apply
      </code>
    </td>
    
    <td>
      A translated document, which you <code>
        render
      </code>
      
       to markdown
    </td>
    
    <td>
      The translated markdown string
    </td>
  </tr>
  
  <tr>
    <td>
      Positions
    </td>
    
    <td>
      Lines of the enclosing top-level block, for documents from <code>
        parse
      </code>
    </td>
    
    <td>
      Exact lines of the node
    </td>
  </tr>
  
  <tr>
    <td>
      Preserves untouched text
    </td>
    
    <td>
      The tree is re-rendered
    </td>
    
    <td>
      Everything outside translated units is preserved byte for byte
    </td>
  </tr>
</tbody>
</table>

Pick the adapter that matches the pipeline of your site. If your renderer works on a comark tree, apply translations there and avoid a round trip through markdown. If it consumes markdown or an mdast tree, use mdast.

## Code comments

Both adapters use `@diglot/code` to extract prose comments from fenced code blocks, unless the policy sets `codeComments` to `false`.


## Sitemap

See the full [sitemap](https://diglot.sh/sitemap.md) for all pages.
