Answers.Body: <p>That syntax looks to be for Redactor 2. The latest versions of the redactor plugin (starting from 2.0) use Redactor 3. The syntax has <a href="https://imperavi.com/redactor/docs/settings/formatting/#s-formattingadd" rel="nofollow noreferrer">changed slightly</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-26T11:16:33.027Z
Answers.LastActivityDate: 2018-10-26T11:16:33.027Z
Answers.UserDisplayName: Andris Sevcenko
Answers.Body: <p>If you encounter an "Invalid Argument – yii\base\InvalidArgumentException Syntax error." while copy-pasting from the <a href="https://imperavi.com/redactor/docs/settings/formatting/#s-formattingadd" rel="nofollow noreferrer">linked documentation</a>, make sure each key and value has quotation marks around them (instead of apostrophes or nothing at all), e.g.: </p>
  
  <p>Instead of this: </p>
  
  <pre><code>"red-p-add": {
      title: 'Red Paragraph',
      api: 'module.block.format',
      args: {
          'tag': 'p',
          'class': 'red-styled'
      }
  },
  </code></pre>
  
  <p>Use this: </p>
  
  <pre><code>"red-p-add": {
      "title": "Red Paragraph",
      "api": "module.block.format",
      "args": {
          "tag": "p",
          "class": "red-styled"
      }
  },
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-11T13:36:55.133Z
Answers.Text: Thanks, this helped me too.
Answers.UserDisplayName: Masiorama
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-06T15:28:36.840Z
Answers.LastActivityDate: 2020-01-06T15:28:36.840Z
Answers.UserDisplayName: Ottó Radics
Body: <p>I've used redactor's custom formatting option before, but now I can't get anything to work. Here's what my file currently looks like:</p>
  
  <pre><code>{
      "buttons": [
          "formatting",
          "bold",
          "italic",
          "lists",
          "link"
      ],
      "formatting": ["p","blockquote"],
      "formattingAdd": {
          "h2": {
              "title": "Heading",
              "args": ["h2"]
          },
          "h4": {
              "title": "Subheading",
              "args": ["h4"]
          },
          "caption": {
              "title": "Caption",
              "args": ["p", "class", "caption"]        
          }
      },
      "buttonsAdd": ["sup", "sub"],
      "linkNewTab": true
  }
  </code></pre>
  
  <p>I have the "h2" and "h4" under "formattingAdd" because I wanted them to use custom titles.</p>
  
  <p>The problem is, none of my custom formats are working. The "p" and "blockquote" from "formatting" are working properly, but the other three styles don't do anything. They appear in the list, but don't restyle the text in the editor, or create the elements in the output. </p>
  
  <p>Is there something in the syntax I'm missing? I'm in Craft 3, with the redactor plugin updated to the latest version.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-18T15:24:35.793Z
Comments.Text: Andrea, did you get this working at all in Craft3?
Comments.UserDisplayName: erwinheiser
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-19T16:09:39.213Z
Comments.Text: Yes, Andris' answer is correct, the syntax changed a little. The args should be expressed as an object instead of an array.
Comments.UserDisplayName: Andrea Hall
Tags: <craft3><redactor>
Title: Redactor formattingAdd not working
ThreadText: # Redactor formattingAdd not working
  
  (Asked by: username_0 on 2018-10-25)
  
  I've used redactor's custom formatting option before, but now I can't get anything to work. Here's what my file currently looks like:
  
  ```
  {
      "buttons": [
          "formatting",
          "bold",
          "italic",
          "lists",
          "link"
      ],
      "formatting": ["p","blockquote"],
      "formattingAdd": {
          "h2": {
              "title": "Heading",
              "args": ["h2"]
          },
          "h4": {
              "title": "Subheading",
              "args": ["h4"]
          },
          "caption": {
              "title": "Caption",
              "args": ["p", "class", "caption"]        
          }
      },
      "buttonsAdd": ["sup", "sub"],
      "linkNewTab": true
  }
  
  ```
  
  I have the "h2" and "h4" under "formattingAdd" because I wanted them to use custom titles.
  
  The problem is, none of my custom formats are working. The "p" and "blockquote" from "formatting" are working properly, but the other three styles don't do anything. They appear in the list, but don't restyle the text in the editor, or create the elements in the output.
  
  Is there something in the syntax I'm missing? I'm in Craft 3, with the redactor plugin updated to the latest version.
  
  **Tags:** craft3, redactor
  
  > **Comments:**
  > **username_1**: username_0, did you get this working at all in Craft3?  
  > **username_0**: Yes, username_2' answer is correct, the syntax changed a little. The args should be expressed as an object instead of an array.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-10-26. Score: 3 | Accepted answer
  
  That syntax looks to be for Redactor 2. The latest versions of the redactor plugin (starting from 2.0) use Redactor 3. The syntax has [changed slightly](https://imperavi.com/redactor/docs/settings/formatting/#s-formattingadd)
  
  
  ---
  
  ### Answer by username_3 on 2020-01-06. Score: 4
  
  If you encounter an "Invalid Argument – yii\base\InvalidArgumentException Syntax error." while copy-pasting from the [linked documentation](https://imperavi.com/redactor/docs/settings/formatting/#s-formattingadd), make sure each key and value has quotation marks around them (instead of apostrophes or nothing at all), e.g.:
  
  Instead of this:
  
  ```
  "red-p-add": {
      title: 'Red Paragraph',
      api: 'module.block.format',
      args: {
          'tag': 'p',
          'class': 'red-styled'
      }
  },
  
  ```
  
  Use this:
  
  ```
  "red-p-add": {
      "title": "Red Paragraph",
      "api": "module.block.format",
      "args": {
          "tag": "p",
          "class": "red-styled"
      }
  },
  
  ```
  
  > **Comments:**
  > **username_4**: Thanks, this helped me too.  
  
  ---
  
  