Add line-height to text within [syntax=php][/syntax] tags

We know you have an opinion on how things should be run around here. These are suggestions for the forums, and the website.This forum is not a place to ask for suggestions to your own coding (or otherwise) problems.

Moderator: General Moderators

Post Reply
MichaelR
Forum Contributor
Posts: 148
Joined: Sat Jan 03, 2009 3:27 pm

Add line-height to text within [syntax=php][/syntax] tags

Post by MichaelR »

At the moment it's quite difficult to read the code people provide because of the lack of line-height/leading. Using { line-height: 1.2; } seems to be the preferred option.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Add line-height to text within [syntax=php][/syntax] tag

Post by McInfo »

If you have Greasemonkey and somewhere to host a CSS file, you can modify the stylesheet however you want (as I do).

This Greasemonkey script appends a new link tag to the head tag of every page on forums.devnetwork.net. The link references a custom stylesheet hosted locally.

Code: Select all

// ==UserScript==
// @name             DevNetwork.net Custom Style
// @namespace        http://localhost/
// @description      Adds a custom stylesheet.
// @include          http://forums.devnetwork.net/*
// ==/UserScript==

var link = document.createElement('link');
link.type = 'text/css';
link.href = 'http://localhost/custom.css';
link.rel = 'stylesheet';
document.head.appendChild(link);
Here is the stylesheet I use.

Code: Select all

.content .syntax {
    background-color: inherit;
    border-width: 0;
    color: #444444;
    display: block;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    line-height: 1.2em;
    margin: 0 0 0 0.2em;
    padding: 0;
    width: auto;
}
.content .syntax-header {
    border-width: 0;
    color: #B4B9BF;
    font-family: Arial, Verdana, Helvetica, sans-serif;
    font-size: 0.8em;
    font-weight: normal;
    margin: 0;
    padding: 0.2em 0;
    text-align: right;
}
.syntax-header a:link, .syntax-header a:visited {
    border-bottom: 1px dotted #B4B9BF;
    color: #B4B9BF;
    text-decoration: none;
}
.syntax-header a:hover, .syntax-header a:active {
    border-bottom: 1px dotted #FF1010;
    color: #FF1010;
    text-decoration: none;
}
.syntax-content {
    background-color: #F4F7F8;
    border-color: #D4D9DF;
    border-style: dotted;
    border-width: 1px 0;
    line-height: 1.2em;
    margin: 0;
    padding: 0;
}
.syntax-content div {
    padding: 0.3em;
}
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Add line-height to text within [syntax=php][/syntax] tag

Post by social_experiment »

MichaelR wrote:At the moment it's quite difficult to read the code people provide because...
I've found that lack of proper indentation and line-lengths of more than 80 characters makes this happen :\

The Greasemonkey and stylesheet idea sounds pretty cool i might give it a go myself.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply