šŖ Reflecting on Last Weekās Progress:When cross-posting from Medium to LinkedIn and DEV.to, I noticed several formatting issues: bold and italic text, as well as ordered and unordered lists, were not displaying correctly. Tags were also not posting accurately, and the URL linking back to the original article didnāt work as expected. After some adjustments, formatting is now accurate, and tags are correctly formatted for each platform.
š Project Update Overview:DEV.to uses Markdown syntax, while LinkedIn does not. LinkedIn also has a 1300-character limit and lacks consistent support for bold and italic formatting. I developed a helper function that formats posts for LinkedIn and DEV.to, adjusting based on the platformĀ input.
šļø KeyĀ Updates:
- Regex Improvements: Posts are now formatted correctly for LinkedIn andĀ DEV.to.
- Tag Extraction from HTML: Tags are properly formatted for each platform.
- Canonical URL Cleanup: Query parameters are removed, so the original article URL now works correctly. š«Ø Challenges & Solutions š”Challenge 1: Bold, italics, and lists werenāt properly formatted for DEV.to and LinkedIn.
Solution:
- LinkedIn doesnāt support bold, italics, or bullet points, so these were replaced with plain text, with numbers used for bulletĀ points.
After converting HTML to Markdown, ensured proper formatting (e.g., italics,Ā bold).
Challenge 2: Tags from Medium werenāt cross-posting correctly.DEV.to limits tags to four, requiring lowercase alphanumeric tags in an arrayĀ format.
LinkedIn allows hashtags to be embedded, but they must be camelCase (no spaces or dashes) and limited to 1300 characters.
Solution:
Adjust tags to meet each platformās requirements.
- For DEV.to: Remove non-alphanumeric characters, convert tags to lowercase, and limit to fourĀ tags.
- For LinkedIn: Remove any prefix hashtags, convert spaces or dashes to camelCase, and re-add theĀ #.
- Kept content within 1200 characters to allow room for title, URL, andĀ tags. Challenge 3: Mediumās RSS feed sometimes includes unnecessary query parameters inĀ URLs.
Solution:
Extract the clean URL for cross-posting.
š Reflection:Working with regex has been fascinating; itās powerful and versatile for various use cases. Iāve used it before in my Fresh Start project for translating directions, which showed me how effective it can be. That said, regex has limitations, so itās essential to use it cautiously, depending on yourĀ needs.
š Check Out the Repo: https://github.com/Jesse-Chong/Cross-post-server
Thank you for reading! Iād love to hear your thoughts.
Originally published at Medium
Top comments (0)