You can create a Google Apps Script for Google Docs that converts any text element ending with a question mark to an H3 element. Here’s a basic example of how you can achieve this:
function convertQuestionToH3() {
var body = DocumentApp.getActiveDocument().getBody();
var paragraphs = body.getParagraphs();
for (var i = 0; i < paragraphs.length; i++) {
var paragraph = paragraphs[i];
var text = paragraph.getText();
// Check if the paragraph ends with a question mark
if (text.slice(-1) === '?') {
// Convert the paragraph to H3 element
paragraph.setHeading(DocumentApp.ParagraphHeading.HEADING3);
}
}
}
Here’s how you can set up and use this script:
- Open your Google Docs document.
- Click on
Extensions
->Apps Script
. - Delete any code in the script editor and replace it with the code provided above.
- Save the script.
- Run the function
convertQuestionToH3()
by clicking the play button or by going toRun
->Run function
->convertQuestionToH3
.
This script will iterate through all paragraphs in the document and if it finds a paragraph that ends with a question mark, it will convert that paragraph into an H3 heading.