Tips on swapping out text with placeholder text like lorem ipsum

I am looking to replace my text with Lorem Ipsum.

What I want is to input my text and receive back Lorem Ipsum that matches the length, case, and punctuation exactly.

For instance,

I, have a text that I want to replace. END;

could turn into

D, quam e leme ntum F erme po tincidu. PUR;

I've searched for a library but haven't quite figured out how to adapt it for my needs yet.

If you have any ideas on achieving this goal, I would greatly appreciate it. My aim is to transform my original text into unreadable text while maintaining its formatting so others can't decipher it. That's why I thought using Lorem Ipsum could be the solution.

I considered taking each paragraph and generating Lorem Ipsum input based on it, but it seems there isn't control over uppercase/lowercase.

Answer №1

Try this method for creating nonsensical text that mimics the structure of inputText.

const jibberRaw = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum';
const jibberLetters = jibberRaw.toLowerCase().replaceAll(/[^a-z]/g, '');
function jibberOfShape(shape) {
    return Array.from(shape).map((char, index) => {
      const charIsLetter = char.match(/[a-zA-Z]/);
      if (charIsLetter) {
        const wasUpper = char === char.toUpperCase();
        const jibberLetter = jibberLetters[index % jibberLetters.length];
        return wasUpper
          ? jibberLetter.toUpperCase()
          : jibberLetter;
      } else {
        return char;
      }
    }).join('');
}

const inputText = 'I, have a random phrase that I need to transform. DONE;';
console.log(inputText);
console.log(jibberOfShape(inputText));

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to showcase a message using if-else conditions in Vue.js?

<div class="dimension-section no-border-radius margin-top-2"> <div class="dimension-size"></div> <div> <ul> <li v-on:click="display = !display" @click="getPartingCharges('5-10')" :class="{ active: is ...

Ways to send a message from a chrome extension to a webpage and patiently await a reply

Currently, I'm exploring ways to send messages from a Chrome extension to a page view and wait for a response. Here's what I've tried so far: In the extension's content_script.js: window.addEventListener('message', function(e ...

Having trouble inputting a value into a textbox after enabling it via Javascript

I'm having trouble setting a value in a textbox after forcibly enabling it through JavaScript executor in my Selenium automation script using Ruby bindings. input_fieldcar1 = browser.find_element(:xpath, "/html/body/div[5]/div/div[3]/div[2]/div[2]/di ...

Tally data from a different table using Sequelize

I need help converting this SQL code to Sequelize: SELECT table1.id, table1.name, (SELECT COUNT(*) FROM table2 WHERE table2.t1_id = table1.id) AS t1_count FROM table1 WHERE .... LIMIT ..... OFFSET .....; Any assistance is appreciated :) ...

Encountered a problem while trying to install using npm install

Encountering an error while running npm install on Ubuntu 12.04: Here is a snippet from my npm-debug.log showing where the errors occur: ... (contents of npm-debug.log) ... This is my package.json: { "name": "www", "version": "0.0.1", /"p ...

Vue.js - experiencing issues with conditional styling not functioning as expected

Can someone help me with an issue I'm having? I've created a button with a heart symbol that is supposed to change color when clicked, but it's not working as expected. This is my current code: <template> <button v-bind: ...

Click on the marker to adjust the map's central position

I've successfully created a leaflet map featuring an array of 3 different locations, each marked with a popup window. Now, I'm looking to implement the functionality that will allow the center of the map to change dynamically when a user clicks o ...

Unable to access an element using jquery

This is an example of an HTML file: <div id ="main"> </div> Here is the JavaScript code: //creating a new div element var divElem = $('<div class="divText"></div>'); //creating an input element inside the div var i ...

Top method for handling chained ajax requests with jQuery

I'm facing a scenario where I have to make 5 ajax calls. The second call should only be made once the first call returns a response, the third call after the second completes, and so on for the fourth and fifth calls. There are two approaches that I ...

Guide on retrieving data parameter on the receiving page from Ajax response call

I am working on dynamically opening a page using Ajax to avoid refreshing the browser. The page opens and runs scripts on the destination page, but before running the script, I need to retrieve parameters similar to request.querystring in JavaScript. Belo ...

Issue encountered in protobuf | npm ERR! code ELIFECYCLE: encountered when configuring Sawtooth JavaScript Transaction Processor on Ubuntu 16.04

Currently delving into the sawtooth example My progress so far : Downloaded and set up the latest version of Node (8.11.3) and npm. Commenced working on javascript essentials using docker-compose up. The hurdles I'm facing: I am looking to config ...

Stop the interval when the variable equals "x"

I've created a function that controls a specific row in my database using AJAX. The function is triggered by a click event and placed within a setInterval function to check ten times per second. Initially, it will return 0, but eventually (usually wi ...

"Utilize JavaScript to assign array values to the main object for efficient data

I am looking to parse a modified JSON file to create separate objects for each team and player. I want each object to have a key for the team name and the player name. Using JavaScript, how can I achieve the following structure: [ { name: 'Dallas St ...

Testing the screen size automatically using Javascript

Hello everyone, I've implemented a JavaScript code that triggers an image to slowly appear and darken the background when a link is clicked. However, on an iPad, the background doesn't completely turn black as intended. The CSS specifies that the ...

Experience the feeling of releasing momentum by click and dragging the scroll

One feature I am looking for is the ability to control the scroll speed when dragging, and have the scroll continue moving slightly after release instead of stopping instantly. CodePen: https://codepen.io/rKaiser/pen/qGomdR I can adjust the speed adequat ...

Ways to determine if an object is either undefined or null

I'm facing an issue that keeps resurfacing, but I can't seem to find a solution for it. In my project, I have 5 divs and I want to hide the div that was previously clicked on. For example, if the user clicks on div 1 and then on div 2, div 1 sho ...

What is the best way to show toast notifications for various selections in a dropdown menu?

I have a dropdown menu labeled "FavoriteFoods" that includes options such as "Pizza," "Sushi," "Burgers," and "Biryani." When one of these food choices is selected from the dropdown, I would like a toast pop-up to appear with the message "Great choice!" ...

What is the process for transforming a Binary field from type 4 to type 0?

Is there a way to convert a Binary field of type 4 to type 0 using a Shell script? I considered executing a simple script such as the one below: db.places.find({}).forEach(function(data) { // How can I access the data? print(data.id); // db. ...

FileReader and Socket.io uploader: each new upload builds upon the previous uploads

I have been working on integrating a file uploader using html5, js, and node which uploads large files in chunks. Everything works perfectly for a single upload. However, when attempting to upload again on the same page, it gets stuck in an endless loop wh ...

Grid items in Material UI are not positioned next to each other

I am encountering an issue with the Grid component in material-ui. The grid items are currently stacking below each other instead of beside each other, and I'm unsure of what is causing this behavior. My intention is for the grid items to stack on top ...