דילוג לתוכן הראשי
יצירתי

קטע קוד

Code Snippet

קטע קוד עם צבעי תחביר בערכת צבעים בהירה או כהה, מספרי שורות, שורות מודגשות וכפתור העתקה.

Code Highlight - ערכה כהה, JavaScript

greet.js JavaScript
// Greets every visitor in their own language.const greetings = { he: 'שלום', en: 'Hello', ar: 'مرحبا' };function greet( name, lang = 'he' ) {	const word = greetings[ lang ] ?? greetings.en;	return `${ word }, ${ name }!`;}console.log( greet( 'Dana' ) );

ערכה בהירה, PHP עם שורות מודגשות

functions.php PHP
<?php// Adds a "Reading time" line under every post title.add_filter( 'the_title', function ( $title, $id = 0 ) {	if ( ! in_the_loop() || 'post' !== get_post_type( $id ) ) {		return $title;	}	$words   = str_word_count( wp_strip_all_tags( get_post_field( 'post_content', $id ) ) );	$minutes = max( 1, (int) ceil( $words / 220 ) );	return $title . ' <small class="reading-time">&amp; ' . $minutes . ' min</small>';}, 10, 2 );

בלי כותרת: CSS עם גלישת שורות, ו-HTML

/* A soft card that lifts on hover - no extra markup needed. */.card {	--lift: 6px;	padding: clamp(16px, 4vw, 32px);	border-radius: 18px;	background: linear-gradient(160deg, #fff, #f4f2ff);	box-shadow: 0 1px 2px rgb(20 23 43 / 6%), 0 18px 40px -20px rgb(20 23 43 / 35%);	transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);}.card:hover { transform: translateY(calc(var(--lift) * -1)); }@media (prefers-reduced-motion: reduce) { .card { transition: none; } }
hero.html HTML / XML
<figure class="hero">	<img src="/images/team.jpg" alt="The team at work" loading="lazy">	<figcaption>Built in Tel Aviv - shipped everywhere</figcaption></figure><script>	document.querySelector( '.hero' ).classList.add( 'is-ready' );</script><style>	.hero { margin: 0; }</style>

גובה מרבי עם גלילה, מספור מ-120

inventory.py Python
def fibonacci(limit: int):    """Yields Fibonacci numbers up to a limit."""    a, b = 0, 1    while a <= limit:        yield a        a, b = b, a + bclass Inventory:    def __init__(self):        self.items: dict[str, int] = {}    def add(self, name: str, count: int = 1) -> None:        self.items[name] = self.items.get(name, 0) + count    def total(self) -> int:        return sum(self.items.values())if __name__ == "__main__":    stock = Inventory()    for n in fibonacci(100):        stock.add(f"item-{n}", n)    print(f"{len(stock.items)} kinds, {stock.total()} units")  # a fairly long trailing comment that runs past the edge
Bash / Shell
# Build only one widget bundle into a private folderPEA_ENTRY=widgets/code-highlight PEA_OUT=/tmp/pea npx wp-scripts buildcp -r /tmp/pea/widgets/* build/widgets/echo "Done: $(ls build/widgets | wc -l) files"